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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Referencing A ComboBox

Status
Not open for further replies.

pcgenie

Technical User
Dec 11, 2003
15
US
I have code on a subform that is referencing another form that is still open (not the parent form, but the main form that has the opening button on it). I'm trying to get the value from a combobox on the main form that contains the data that will filter the subform in question. The error that I get is a little popup window asking Enter Parameter Value and there's a yellow highlight over Me.RecordSource = strSQL2. When I put the "I" bar cursor over the formula there's a correct value for strSQL2, but Me.RecordSource give me a "". The Me.RecordSource = strSQL seems like it should work, but it doesn't. What am I doing wrong.
See below.
==========================================
Dim strForm As String
Dim strSQL1 As String, strSQL2 As String, strWhere As String
Dim strSelect As String, strFrom As String, strJoin As String

strSelect = "SELECT tblMainData.* "
strFrom = "FROM tblMainData "
strJoin = "INNER JOIN tsubPermissionList ON
tblMainData.ResponsibleParty = tsubPermissionList.FullName "
strWhere = "WHERE tsubPermissionList.UserID = " &
Forms!frmMainEntry!cboSelectUser
strSQL1 = strSelect & strFrom & strJoin
strSQL2 = strSelect & strFrom & strJoin & strWhere

If
IsNull(Forms("frmMainEntry").Form.Controls("cboSelectUser").Value) Then
' If the combo is Null, use the whole table as the RecordSource.
Me.RecordSource = strSQL1
Else
Me.RecordSource = strSQL2
End If
==========================================
Thanks,
PC
 
If UserID is not numeric:
strWhere = "WHERE tsubPermissionList.UserID[tt]='"[/tt] & Forms!frmMainEntry!cboSelectUser & [tt]"'"[/tt]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top