Results 1 to 15 of 15
  1. #1
    OllieUk is offline Novice
    Windows 10 Office 365
    Join Date
    May 2022
    Posts
    4

    Post Form property

    I am trying to get a field to either be shown or hidden depending on a value of another field when the form opens.

    if me.text box.value =“2” then
    me.text2.Visible=true


    else
    me.text2.Visiblefalse


    end if

    When I run it comes up with a notice “ object not found “

    can anyone help

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    Use:
    me.text2.Visible=Me.text2=“2”

  3. #3
    OllieUk is offline Novice
    Windows 10 Office 365
    Join Date
    May 2022
    Posts
    4

    Visible

    Quote Originally Posted by ranman256 View Post
    Use:
    me.text2.Visible=Me.text2=“2”
    Have tried this but get Error message
    Compile Error
    Method or Data member not found (highlight the .Visible =)

    My actual original as below

    Private Sub AgencyID_AfterUpdate()
    If AgencyID.Value = "2" Then
    Me.Cost.Visible = True
    Else
    Me.Cost.Visible = False
    End If
    End Sub

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,543
    Check that you have named the textbox correctly
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    OllieUk is offline Novice
    Windows 10 Office 365
    Join Date
    May 2022
    Posts
    4
    Hi Bob
    Yes text box is correctly named

  6. #6
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,543
    Can you post a copy of the db to illustrate the problem
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  7. #7
    OllieUk is offline Novice
    Windows 10 Office 365
    Join Date
    May 2022
    Posts
    4
    Sorry cannot post db as comes under data protection

  8. #8
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,543
    We don't need to see your real data. Copy the db. Delete any sensitive records from data. Create a couple of dummy records to illustrate the problem.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  9. #9
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,928
    Quote Originally Posted by OllieUk View Post
    Sorry cannot post db as comes under data protection
    Put it this way.
    Access does not suddenly decide not to recognise an object.
    It is always that it cannot find the object as the reference or name are incorrect.

    When you post it here, a human can recognise the error, Access cannot.

    So when it says it cannot find the control, it is telling the truth.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  10. #10
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    If .Visible is what raises the error, there is something deeper going on. First I'd suggest copying code and pasting in between code tags (use # button on posting toolbar). Don't type it in here for various reasons. Or I'd remove the control, save and close the form and then add the control back again in design view, save, close and reopen.

    EDIT
    So when it says it cannot find the control, it is telling the truth.
    Except the message is about not finding the object OR recognizing a method of the object that it can find.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  11. #11
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,543
    While I don't have the knowledge and experience that is abundant in many of the responders here, I have been around long enough to feel confident in saying that whatever is wrong with the db, simply giving us a copy is likely to make solving the problem a whole lot simpler.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  12. #12
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    @ollieUK
    As others have said, we need to see the issue in context. If the data is private, then make some dummy data in a copy of the database--enough to show the issue - and post it.

  13. #13
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,928
    Quote Originally Posted by Micron View Post

    Except the message is about not finding the object OR recognizing a method of the object that it can find.
    Method or Data member not found

    I took that to mean that either Cost does not have a Visible property/method, or control Cost could not be found on the form it is meant to be on?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  14. #14
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,543
    Quote Originally Posted by Welshgasman View Post
    [/COLOR]I took that to mean that either Cost does not have a Visible property/method, or control Cost could not be found on the form it is meant to be on?
    Precisely the point I was trying to make earlier. Unless or until the OP posts a copy all anyone can do is guess about what is wrong.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  15. #15
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    On top of all the good advice received from everybody that contributed you should probably try without the double quotes if the AgencyID field is numeric (as it should be):
    Code:
    If Me.AgencyID = 2 Then
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 03-09-2021, 05:52 PM
  2. Replies: 9
    Last Post: 05-30-2017, 04:11 PM
  3. Replies: 2
    Last Post: 11-09-2016, 05:54 PM
  4. Replies: 3
    Last Post: 07-20-2012, 11:41 AM
  5. Change form property with VBA
    By jmk909er in forum Forms
    Replies: 1
    Last Post: 10-20-2010, 08:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums