Results 1 to 5 of 5
  1. #1
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496

    Open form using id from drop down as parameter

    I have a combobox on a form with given areas



    I would like the button to retrieve the combobox area id and then open the form using it

    I was thinking

    DoCmd.OpenForm "frmSchools", , , "AreaID = Me.cmbAreaSelector"

    The combobox is unbound.

    I of course get erros.

    Picture
    Click image for larger version. 

Name:	Capture.JPG 
Views:	10 
Size:	16.1 KB 
ID:	13669

  2. #2
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    I'm guessing I will have to store the value as a temp var in order to store the value for the parameter on the other form?

  3. #3
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    I used a TempVars! in the vba - after adding it to the combo box "on change"

    Works

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    I've never used TempVars.

    Problem with your original code is the variable is within quote marks. That results in the literal string "Me.cmbAreaSelector" instead of the value in Me.cmbAreaSelector. Must concatenate variables, not enclose in quotes.

    DoCmd.OpenForm "frmSchools", , , "AreaID = " & Me.cmbAreaSelector
    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.

  5. #5
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by June7 View Post
    I've never used TempVars.

    Problem with your original code is the variable is within quote marks. That results in the literal string "Me.cmbAreaSelector" instead of the value in Me.cmbAreaSelector. Must concatenate variables, not enclose in quotes.

    DoCmd.OpenForm "frmSchools", , , "AreaID = " & Me.cmbAreaSelector
    Yup, that works a lot better than my method - thanks June

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

Similar Threads

  1. Replies: 2
    Last Post: 08-07-2013, 07:44 AM
  2. Need Parameter Query to Open Form
    By HLTAYLOR in forum Misc
    Replies: 3
    Last Post: 06-20-2013, 09:41 AM
  3. Replies: 1
    Last Post: 02-28-2013, 01:20 PM
  4. Open form from a drop down list
    By ildanach in forum Forms
    Replies: 15
    Last Post: 05-21-2009, 05:40 AM
  5. Open Form with a drop down list box
    By Rinehart in forum Forms
    Replies: 0
    Last Post: 08-10-2008, 08:53 PM

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