Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo box woes

Status
Not open for further replies.

trenttc

Technical User
Joined
Feb 25, 2002
Messages
68
Location
US
I tried faq 702-4289 (combo box dependent on combo box).
I keep getting Enter Parameter Value Forms!MyForm!cboFirstBox
t1
NUMBER
NAME
t2
NUMBER
CODE

First Box Row Source:
SELECT t1.NAME,t1.NUMBER
FROM t1;

Second Box Row Source:
SELECT t2.NUMBER, t2.CODE
FROM t2
WHERE (((t2.NUMBER)=[Forms]![MyForm]![cboFirstBox]))
ORDER BY t2.CODE;

I created a relationship between t1.NUMBER and t2.NUMBER (only include rows where joined fields are equal).

Private Sub cboSecondBox_GotFocus()
If Len(Trim(Nz(cboFirstBox, "") & "")) = 0 Then
MsgBox "Specify Name"
cboFirstBox.SetFocus
Else
cboSecondBox.Requery
End If
End Sub

Private Sub cboFirstBox_AfterUpdate()
cboSecondBox.Requery
End Sub

Any suggestions would be appreciated.
 
Are cboFirstBox and cboSecondBox in a main form named MyForm ?
Another way:
Code:
Private Sub cboFirstBox_AfterUpdate()
  Me!cboSecondBox.Rowsource = "SELECT t2.NUMBER, t2.CODE FROM t2" _
   & " WHERE t2.NUMBER='" & Me!cboFirstBox & "' ORDER BY t2.CODE"
End Sub
If NUMBER is defined as numeric, then get rid of the single quotes.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
The form is named MyForm. I made the code an event and no longer get the error (why does it make a difference?). Sadly, there's nothing in the second box. If I enter a valid code in the second box, I get "the text you entered isn't an item in the list" message.
All fields are text (no numeric).
I am linking to these tables vs. creating them in Access. I can manually open and alter the linked table fields, so I should be able to do the same with the form.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top