Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    May 2002
    Location
    Jerusalem, Israel
    Posts
    187
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VBA: Open Data Access Page (Access 2000)

    Hi. I'm having a VBA code problem. I want to say that if you select "NY" or "LA" from the drop down menu (City) then open a Data Access Page called NYorLA. This works, but if I choose something other than NY or LA from the dropdown list I get an error message that it requires a Data Access Page Name argument.

    How do I say: if you select "NY" or "LA" from the drop down menu (City) then open a Data Access Page called NYorLA but if you select anything other than NY or LA from the dropdown list (City) then do nothing?

    Here is my code:

    Private Sub City_AfterUpdate()
    If [Forms]![frm_Search for Order-Number]![City] = "NY" Or [Forms]![frm_Search for Order-Number]![City] = "LA" Then stDocName = "NYorLA"
    DoCmd.OpenDataAccessPage stDocName, acDataAccessPageBrowse
    End Sub

    Thanks for your help,

    Joe

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: VBA: Open Data Access Page (Access 2000)

    Try this:

    Private Sub City_AfterUpdate()
    If [Forms]![frm_Search for Order-Number]![City] = "NY" Or [Forms]![frm_Search for Order-Number]![City] = "LA" Then
    stDocName = "NYorLA"
    DoCmd.OpenDataAccessPage stDocName, acDataAccessPageBrowse
    End If
    End Sub

    Since City is on the active form, you don't need to use Forms!...

    Private Sub City_AfterUpdate()
    If Me.City = "NY" Or Me.City = "LA" Then
    stDocName = "NYorLA"
    DoCmd.OpenDataAccessPage stDocName, acDataAccessPageBrowse
    End If
    End Sub

  3. #3
    2 Star Lounger
    Join Date
    May 2002
    Location
    Jerusalem, Israel
    Posts
    187
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBA: Open Data Access Page (Access 2000)

    I didn't do End If!!!!

    Thanks - I never had VBA training and I'm learning on the job, so I appreciate the pointer about making the code tighter by using Me.City rather than Forms!

    Thanks again, Hans.

    Joe

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •