Results 1 to 9 of 9
  1. #1
    kelann is offline Learning ... thank you!!
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    132

    Multiple "WHERE" condition on form button not recognizing existing field

    Hi, all!



    I have a report and a form both drawn from the same table (ResponsesT).

    The report (TrackEventRep) contains the following (among others):
    A button (ButtonUpdateStatusForm).
    Fields RespEventName and RespOrgName.

    The button opens a form (TrackUpdateStatusF) that contains the following (among others):
    Fields RespEventName and RespOrgName. Same field names as the report.

    The button is supposed to open the form so that a particular organization's RSVP status for a particular event can be updated; thus it should open the form for the record that equals both RespOrgName and RespEventName.

    Here's my Event Procedure for the button:
    Private Sub ButtonUpdateStatusForm_Click()
    DoCmd.OpenForm "TrackEventStatusF", acViewPreview, , "RespOrgName=" & Me.RespOrgName & " AND RespEventName=" & Me.RespEventName & "'"
    End Sub
    However, I am getting Run-time error '2465' that says "Microsoft Access can't find the field 'RespEventName' referred to in your expression. I've checked and checked and checked, and it's there, with no typos. I've googled and googled and googled to make sure I have the best understanding of the language.

    Any thoughts, you master debuggers????

    Thank you so much!

    --ak

  2. #2
    kelann is offline Learning ... thank you!!
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    132
    Rats! Now it's changed it's mind and is giving me this error!

    Compile error:

    Method or data member not found, and it highlights Me.RespOrgName

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    If RespOrgName and RespEventName are text fields then need apostrophe delimiters for the criteria (you have a lone apostrophe after RespEventName):

    "RespOrgName='" & Me.RespOrgName & "' AND RespEventName='" & Me.RespEventName & "'"

    Date/Time type would use # delimiters, number type no delimiters.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    kelann is offline Learning ... thank you!!
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    132
    Thank you, June!

    I've updated the code as follows, but it's still giving me "can't find the field RespEventName".

    DoCmd.OpenForm "TrackEventStatusF", acViewPreview, , "RespOrgName='" & Me.RespOrgName & "' AND RespEventName='" & Me.RespEventName & "'"

    Any furhter thoughts?

    Much appreciated!!!!!

    --ak

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I don't follow your process. You open a REPORT to open a Form??? Seems backwards to me. AFAIK, you can't select a record on a report to get variables that would then be used to filter a form. (But I don't use A2010)

    Code:
    DoCmd.OpenForm "TrackEventStatusF", acViewPreview, , "RespOrgName='"  & Me.RespOrgName & "' AND RespEventName='" &  Me.RespEventName & "'"
    And if you open the form in print preview mode (acViewPreview), you wouldn't be able to set the RSVP status anyway.

    Check the control name on the form.
    Check the Control source in the control.
    Delete the control and re-add it. (worked for me several times- some kind of corruption)

  6. #6
    kelann is offline Learning ... thank you!!
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    132
    Well, what they have is a report of everyone's status as to who is coming and who isn't, etc., and after viewing the report, they might want to update the status of one of the organizations.

    Thanks, re acViewPreview -- I deleted that part. I would like to add "duh!"

    You might be right ... re variables on a report ... I surely don't know! I am learning, but I'm not as far as those details yet!!

    Thoughts, anyone?

    Alternatives that immediately pop to mind?

    --ak

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    I just tested a button on a report to Debug.Print a value from the current record. The button is in the Detail section. Report in ReportView. The button works.

    This was with Access 2007.

    I tested ! (bang) and . (dot) in the code.

    Either should work but . (dot) provokes intellisense popup tips in VBA.

    I will look at your db posted in other thread.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    There isn't a form named TrackEventStatusF. I changed code to TrackUpdateStatusF. I put the RespEventName field in Detail section and the code runs.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    kelann is offline Learning ... thank you!!
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    132
    June,

    1. I am a moron. You don't know how many times I looked at those verifying the accuracy of the field name!!
    2. You are a genius! I would never have thought that moving that into the detail section would have made a difference.

    Thank you so very, very much!

    --ak

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

Similar Threads

  1. Replies: 11
    Last Post: 03-29-2012, 02:32 PM
  2. Replies: 0
    Last Post: 01-11-2012, 12:34 PM
  3. Replies: 3
    Last Post: 01-02-2012, 07:48 PM
  4. Replies: 13
    Last Post: 07-27-2011, 12:38 PM
  5. Replies: 16
    Last Post: 07-22-2011, 09:23 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