I have a form (frmSearch) with a couple of listboxes (lstSearchName, lstSearchNickname).When the user double clicks an item in the listbox a new form opens up(frmInfo) that is populated by a query (qryRoster). From what I have found, is that you can not use a variable in a query but can reference a function. I can't get it to work. Here is what I have:
I have a module with this code:
Option Compare Database
Option Explicit
Public strQuery As String
Public Function GetName() As String
GetName = strQuery 'It doesn't seem like strQuery is available here
End Function
On the form I have:
Option Compare Database
Public strQuery As String
Private Sub lstSearchName_DblClick(Cancel As Integer)
strQuery = lstSearchName.Column(3) 'This works strQuery has the data
DoCmd.OpenForm "frmValidateInfo"
End Sub
^This should feed the variable (text data) to the query
The query is:
SELECT tblRoster.LName, tblRoster.FName, tblRoster.Address, tblRoster.City
FROM tblRoster
WHERE (tblRoster.LName)=getName();
What am I doing wrong?
I have a module with this code:
Option Compare Database
Option Explicit
Public strQuery As String
Public Function GetName() As String
GetName = strQuery 'It doesn't seem like strQuery is available here
End Function
On the form I have:
Option Compare Database
Public strQuery As String
Private Sub lstSearchName_DblClick(Cancel As Integer)
strQuery = lstSearchName.Column(3) 'This works strQuery has the data
DoCmd.OpenForm "frmValidateInfo"
End Sub
^This should feed the variable (text data) to the query
The query is:
SELECT tblRoster.LName, tblRoster.FName, tblRoster.Address, tblRoster.City
FROM tblRoster
WHERE (tblRoster.LName)=getName();
What am I doing wrong?