473,385 Members | 1,429 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Advancing unbound combo box

3
Hello,

I’m sure this is a relatively easy fix, but I have an unbound combo box on a form that runs numerous queries in the After Update section. Everything there works fine. All I need to do is have a command button on the form that advances the focus of the combo box to the next record in the query its row source is based on (plus I’m sure it will need an error catcher when it gets to the end of the list). I know how to advance the form’s record with a button, but neither the form nor the combo box are bound. I’m sure someone knows off the top of their head, so I thought I would ask, since googling for an hour has turned up no results.

Thanks in advance.
May 21 '07 #1
6 13529
JConsulting
603 Expert 512MB
Hello,

I’m sure this is a relatively easy fix, but I have an unbound combo box on a form that runs numerous queries in the After Update section. Everything there works fine. All I need to do is have a command button on the form that advances the focus of the combo box to the next record in the query its row source is based on (plus I’m sure it will need an error catcher when it gets to the end of the list). I know how to advance the form’s record with a button, but neither the form nor the combo box are bound. I’m sure someone knows off the top of their head, so I thought I would ask, since googling for an hour has turned up no results.

Thanks in advance.
for clarity sake...you want to select the first item in the combo box...it runs queries. You push a button and the next item in the combo box is "clicked"...etc...until all items are done.?
May 22 '07 #2
Rig20
3
for clarity sake...you want to select the first item in the combo box...it runs queries. You push a button and the next item in the combo box is "clicked"...etc...until all items are done.?
Well, my combo box works perfectly and runs all the code that I have set up for it. All I want to do is have a command button that takes the combo box to the next record (in the drop down list) rather than clicking combo, selecting the next record, etc. My form is designed to look through many records so to be able to go to the next record in the combo quickly would be handy. For the button, I don't think I can use:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.GoToRecord , , acNext
because my form is unbound. Somehow I need to reference the combo and have it go to the next record in its list.

Thanks for your help.
May 22 '07 #3
JConsulting
603 Expert 512MB
Well, my combo box works perfectly and runs all the code that I have set up for it. All I want to do is have a command button that takes the combo box to the next record (in the drop down list) rather than clicking combo, selecting the next record, etc. My form is designed to look through many records so to be able to go to the next record in the combo quickly would be handy. For the button, I don't think I can use:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.GoToRecord , , acNext
because my form is unbound. Somehow I need to reference the combo and have it go to the next record in its list.

Thanks for your help.
put this in a code module
Expand|Select|Wrap|Line Numbers
  1. Function AdvanceCombo(strForm As String, strControl As String)
  2. 'This function clears all entries on all listboxes on the form strForm
  3. Dim c As Control
  4. Dim F As Form
  5. Dim I As Long
  6. Dim cValue As String
  7. Set F = Forms(strForm)
  8. Set c = F(strControl)
  9. cValue = c.Value
  10. For I = 0 To c.ListCount - 1
  11. If c.ItemData(I) = cValue Then c.Value = c.ItemData(I + 1)
  12. Next I
  13. End Function
  14.  
for your button code
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command15_Click()
  2. AdvanceCombo Me.Name, "cboTest" '<---replace cbotest with your combo name
  3. End Sub
  4.  
J
May 22 '07 #4
Rig20
3
Shiny! Thanks for your help. I don't think I would have discovered that on my own.

BTW, I had make the button redo the After Update of the combo, because it did not do it automatically, just in case anyone else has a similar problem. The finished button looks like this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdnext_Click()
  2. AdvanceCombo Me.Name, "cboName"
  3. cboName_AfterUpdate
  4. End Sub
Thanks again!
May 22 '07 #5
Aviqq
3 2Bits
Do you have a code for doing the opossite? I would like to go to previous record rather than advance.

Also, If the combobox is null, is there anyway to go to the first record in the combobox rather than an error popping up? Currently I get Run-time error '94' Invalid use of Null. This also occurs when there is no more selections available in the combobox. Could the selections wrap around back to the begging? Thank you.
Apr 27 '23 #6
jimatqsi
1,271 Expert 1GB
Rig20,
You have hit on one of the real annoying features of a combo box. You have to click, scroll and click to make a choice. I rarely place a combo box on my forms anymore because of that.

You may have avoided this problem altogether by using a list box instead of a combo box. It depends on how much space you've got on your form, and perhaps the number of rows in the combo box and maybe some other things unique to your particular situation. But, if you had a list box instead of a combo box, and the choices were not too numerous, that list box would have served as your command button right there. Just click the member of the list and launch the same code you would have with the combo box.

Food for thought in the future!

Jim
Apr 28 '23 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Megan | last post by:
I'm using an unbound combo box on a form as a record selector. I'm using the combo box to choose certain types of music, i.e. Alternative, Pop, Rock, etc…and then run a report based on the...
2
by: Todd | last post by:
Hello, I'm curious if anyone knows of a way (if one exists) to tell a form (in Access 2002 VBA) to sort on an unbound column of a combo box on the form. Here's what I want to do: A combo box...
2
by: Todd | last post by:
Hi. I want to sort the records on my form (using either a continuous form or a datasheet) by the unbound "description" column in a combo box on the form (or in the datasheet.) Here's a rough...
2
by: Wolfgang Kreuzer | last post by:
Hello all, I am converting an Axs 2.0 application to a2k (I know A2K is not the most current version but Axs 2.0 support ended and A2K is supported in our company amd on every PC). The form is...
3
by: Stig | last post by:
Hi, Any help on this one will be greatly appreciated as I have spent too long banging my head against the screen trying to get it sorted. Basically I would like to have a select all records...
20
by: Robert | last post by:
Need some help to stop me going around in circles on this one.... Have a nested subform (subform2) which simulates a continuous form for the record on the parent subform. Subform2 has rows of...
8
by: Robert | last post by:
I have a form (Worksheet) that works fine by itself. I have now created a seperate form (MainForm) that has a command button in the header and an unbound subform (FormFrame) in the Detail section....
10
by: themightypea | last post by:
Hi, I'm attempting to create a continuos form which allow the user to edit various fields for each item. Unfortunately, the data I need is spread over multiple tables so binding the control to the...
9
by: prakashwadhwani | last post by:
I have an unbound combo box in the form header. I have used an input mask "CCCC" 40 times to limit the max number of characters to 40. When I tab into the combo box & press a character say "K"...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.