MSeda
Thanks for the reply. I'm still having problems though. Here's exactly what I'm doing....maybe you can see where I'm going wrong.
In a blank form I added a combo box that includes fields: MEDRECNO, LNAME, and FNAME. Sort ascending by LNAME. Combo box label is MEDRECNO. Listed as 'Combo8' in the property sheet.
I click on the combo boxs' dropdown(which says 'unbound'), and go to code builder for the 'On Key Down' event. Then I paste this in:
- Private Sub Combobox1_KeyDown(KeyCode As Integer, Shift As Integer)
-
-
If KeyCode = 13 Then '13 is the enter key so the event only occurs when the enter key is pressed
-
Docmd.openform “OncRegMain”, ,,”[MEDREDNO] = ” & me.Combobox1 'open the form where medrecno matches the record in your combobox assuming medrecno is the bound column of the combobox otherwise refer to its column
-
Docmd.close acform, me.form.name 'close the search form
-
End If
-
-
End Sub
Some changes that I think should be made for my specific problem is:
Change:
- Private Sub Combobox1_KeyDown(KeyCode As Integer, Shift As Integer)
To:
- Private Sub Combo8_KeyDown(KeyCode As Integer, Shift As Integer)
Then change:
- Docmd.openform “OncRegMain”, ,,”[MEDREDNO] = ” & me.Combobox1
To:
- Docmd.openform “OncRegMain”, ,,”[MEDREDNO] = ” & me.Combo8
For the above line, MEDRECNO is the first column in the combo box, and the bound column is set to 1. Does that mean that MEDRECNO is the bound column?
When I do this and test it, I get a syntax error on the following line:
- Docmd.openform “OncRegMain”, ,,”[MEDREDNO] = ” & me.Combobox1 'open the form where medrecno matches the record in your combobox assuming medrecno is the bound column of the combobox otherwise refer to its column
When I first paste the whole series of code, the above line shows up in red(don't know what that means). It also highlights [MEDRECNO] on that line and says Compile Error: "Expected end of statement". Is the syntax correct or should there be quotes removed or added somewhere?