Results 1 to 5 of 5
  1. #1
    moneypennie21 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    41

    open form based on combo box value

    Hi I am trying to use a combo box on a dashboard form to open another form to a specific record. I have tried variations on the openform command and openargs but I am quite new to access so I am probably doing something wrong somewhere. I have attached a test version of a simple database that shows the problem I ma having the code on click event of command5 button is



    Private Sub Command5_Click()
    DoCmd.OpenForm "Frm_Table1", acNormal, , "Visit_ID = " & Me.Combo23 & ""
    End Sub

    Please can someone advise what I need to do to resolve this?

    Thanks

    JBranch visit access.zip

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    DoCmd.OpenForm "Frm_Table1", , , "Visit_ID = " & Me.Combo23

    your code is correct providing:
    the table field name is: Visit_ID
    the field is numeric
    the combo value is not null
    the combo value IS bound to the correct column#

    UPDATE:
    your combo column is bound to ID, not VISIT_id

  3. #3
    moneypennie21 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    41
    Hi ranman256,

    Thank you for the update, how do i change this? I have tried changing the bound column property on the combo to 2 but this doesn't work properly either. what do I need to do to resolve?Click image for larger version. 

Name:	Capture.JPG 
Views:	13 
Size:	38.1 KB 
ID:	37848

    Thanks

    J

  4. #4
    moneypennie21 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    41
    I have made a change now as I wanted a random ID generated which I have done after a fashion but now the format of the field in the table is text even though the result is a number I have tried adding [] round the field name but I get run time error 3075

    Syntax error (missing operator) in query expression '[visit_ID] = 237366 (this is the id I am searching for so part of the code is working)! I have added an updated version of the db to see if anyone can help with this

    the code I am using is


    Private Sub Command5_Click()
    DoCmd.OpenForm "Frm_Table1", acNormal, , "[Visit_ID] = " & Me.Combo23 & """"""
    End Sub




    Thanks J
    Attached Files Attached Files

  5. #5
    moneypennie21 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    41

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

Similar Threads

  1. Replies: 5
    Last Post: 08-06-2014, 02:39 PM
  2. Replies: 3
    Last Post: 06-18-2014, 10:40 AM
  3. Replies: 22
    Last Post: 05-10-2014, 04:43 PM
  4. Replies: 1
    Last Post: 10-30-2012, 10:29 AM
  5. Replies: 5
    Last Post: 01-02-2011, 10:09 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