Results 1 to 7 of 7
  1. #1
    mauryc1990 is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    9

    Move to next record in combobox


    Hi,

    I want to create a code in VBA which take a first value in my combobox (list of value from Table X), run a query and after go to next record from combobox.

    Any ideas?

  2. #2
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    What does the query do, what do you want done with the data? Is it adding it to a table? If this is a continuous process, write a VBA routine to loop thru the records and run the query for each one.

  3. #3
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    What have you tried?

    The combo box bound value is available to you using Me.YourComboName in VBA or you could refer to it directly in a saved action query.

  4. #4
    mauryc1990 is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    9
    I want to use value from combobox in query, but I don't understand how to go through next record?

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    I have a suspicion that you are using lookups at the table field level. Please tell us in plain English "what" you are trying to accomplish --no jargon and no database terms--plain English.
    What does your table(s) represent?

  6. #6
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    I remain in ignorance as to what the query does, how it is to be used, what its purpose is. However, here is some code. It needs something to run it, a trigger of some sort, I have used a command button that will run this code when it is clicked.

    Code:
    Private Sub Cmd_Loop_Click()
        Dim rst As Recordset, strSQL As String
        
        strSQL = "put the SQL for your combobox here"
        Set rst = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)
        rst.MoveFirst
        
        Do Until rst.EOF
            DoCmd.RunSQL "put your query SQL here...." & rst!FieldName & "....;"
            rst.MoveNext
        Loop
        
    End Sub

  7. #7
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    mauryc1990,

    I recommend that you tell us about your requirement/plan in plain, simple English. What exactly is your database/table design(s)?

    Where is your combobox?
    What is the rowsource of the combobox?

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

Similar Threads

  1. Replies: 2
    Last Post: 05-17-2017, 09:49 AM
  2. Replies: 3
    Last Post: 02-06-2015, 01:18 PM
  3. Replies: 1
    Last Post: 02-01-2015, 12:16 AM
  4. Replies: 3
    Last Post: 12-11-2014, 11:26 AM
  5. Replies: 5
    Last Post: 06-16-2013, 05:25 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