Full Version: combo box query
UtterAccess Forums > Microsoft® Access > Access Forms
bbarnett100
Hello. I have a form called frmpremise and have placed a combo box on it that is meant to find the record on the form that is selected from the drop down combo box.( premise_id, premise_name) At present , regardless of whatever you select first from the combo drop down , it always defaults to record one. After that , there is no problem and it correctly displays whatever is selected. Ther must be a simple solution , but I havent found it yet. Can anyone help ?
2ME
hi, bbarnett100
o you mean the first record in the form even if you have't select the permise_id from the combobox?
if so, set the Data Entry property to yes
Hope that helps...
bbarnett100
Thanks for your reply. The data entry property is set to no. If it is set to yes , it doesnt show anything at all. Let's say I have four records Ill call them 1,2,3,4. Whichever I choose from the drop down , it will always show record 1. If I then choose 3, it will show 3 and so on. Its only the first choice after the from has opened that doesnt respond properly.
2ME
hi, bbarnett100
Is I can see from your post, you get the first row selected automatically when you open your form and you need to make it blank
if you have a code like this in your form On Current event :
Me![ComboName] = Me![ComboName].ItemData(0)
If you removed this line that will set the combo blank
because this code makes the first row selected automatically
Hope this helps...
jmcwk
If I may ask what is the code behind the Combo Box in the After Update Event ? Did you use the combo box wizard and select the 3rd option to find your record ?
bbarnett100
Hello. Yes I did. The code is thus...
Private Sub Combo220_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[Premise_id] = " & Str(Nz(Me![Combo220], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

End Sub
ve actually solved my problem. When the form is opened , the detail section is invisible.I then included this in the after udate
Me.Detail.Visible = True
However if I put it at the end , I had my prblem. By placing it at the beginning, it solves my problem.
Private Sub Combo220_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Me.Detail.Visible = True
Set rs = Me.Recordset.Clone
rs.FindFirst "[Premise_id] = " & Str(Nz(Me![Combo220], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
'NOT HERE WHERE IT WAS BEFORE..'
End Sub
many thanks to all of you
jmcwk
Thanks for posting the code and your solution Glad you worked it out ertical-align:middle" emoid=":thumbup:" border="0" alt="thumbup.gi
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.