G
Guest
I know I'm doing this the wrong way; I may also be doing this the long way
I have a table with students' names and ID numbers. To retrieve a record, I
provide a pop-up, frmRecordLookup, where either indexed field can be entered,
either in full or in part. For instance, rather than retrieving a long list
of Smith's, the user could enter "joh smi", and a list matching "joh* smi*"
would be displayed; the entry "smith" would be transformed into "* smith*".
The After Update routine intends to display on frmSelectRecord the retrieved
names and IDs, along with other identifying information, so that the user may
select the correct record to update. lstSelectRecord, a listbox on
frmSelectRecord, has the recordsource "SELECT * FROM qryFindName".
qryFindName contains the code
PARAMETERS prm_strSearch Text ( 255 );
SELECT strApplicantName, pk_strID, [...]
FROM tblRatingDetail
WHERE strApplicantName Like prm_strSearch;
The query runs correctly from the database window, as the parameter is
directly input.
I have tried to set the parameter to the query in several ways.
txtName_AfterUpdate in Form_frmRecordLookup contains
Private Sub txtApplicantName_AfterUpdate()
Dim bytSpace As Byte
Dim strSearch As String
bytSpace = InStr(txtApplicantName, " ")
If bytSpace Then
strSearch = Left$(txtApplicantName, bytSpace - 1) & "* " &
Right$(txtApplicantName, Len(txtApplicantName) - bytSpace) & "*"
Else
strSearch = "* " & txtApplicantName
End If
DoCmd.Close
CurrentDb.QueryDefs!qryFindName!prm_strSearch = strSearch
DoCmd.OpenForm "frmSelectRecord"
End Sub
I have tried making frmSelectRecord bound to qryFindName; I've tried it
unbound. In lieu of opening the form, I've tried
DoCmd.OpenQuery "qryFindName"
I've tried deleting the parameter statement, changing
DoCmd.OpenForm "frmSelectRecord",OpenArgs:=strSearch
and adding
CurrentDb.QueryDefs!qryFindName!prm_strSearch = OpenArgs
to Form_Open in the Form_frmSelectRecord module.
With every option, the parameter pop-up appears! HELP!!!
Must I use object variables with parameters? Must I requery after setting
the parameter in Form_Open? WHAT am I doing WRONG?!?
I have a table with students' names and ID numbers. To retrieve a record, I
provide a pop-up, frmRecordLookup, where either indexed field can be entered,
either in full or in part. For instance, rather than retrieving a long list
of Smith's, the user could enter "joh smi", and a list matching "joh* smi*"
would be displayed; the entry "smith" would be transformed into "* smith*".
The After Update routine intends to display on frmSelectRecord the retrieved
names and IDs, along with other identifying information, so that the user may
select the correct record to update. lstSelectRecord, a listbox on
frmSelectRecord, has the recordsource "SELECT * FROM qryFindName".
qryFindName contains the code
PARAMETERS prm_strSearch Text ( 255 );
SELECT strApplicantName, pk_strID, [...]
FROM tblRatingDetail
WHERE strApplicantName Like prm_strSearch;
The query runs correctly from the database window, as the parameter is
directly input.
I have tried to set the parameter to the query in several ways.
txtName_AfterUpdate in Form_frmRecordLookup contains
Private Sub txtApplicantName_AfterUpdate()
Dim bytSpace As Byte
Dim strSearch As String
bytSpace = InStr(txtApplicantName, " ")
If bytSpace Then
strSearch = Left$(txtApplicantName, bytSpace - 1) & "* " &
Right$(txtApplicantName, Len(txtApplicantName) - bytSpace) & "*"
Else
strSearch = "* " & txtApplicantName
End If
DoCmd.Close
CurrentDb.QueryDefs!qryFindName!prm_strSearch = strSearch
DoCmd.OpenForm "frmSelectRecord"
End Sub
I have tried making frmSelectRecord bound to qryFindName; I've tried it
unbound. In lieu of opening the form, I've tried
DoCmd.OpenQuery "qryFindName"
I've tried deleting the parameter statement, changing
DoCmd.OpenForm "frmSelectRecord",OpenArgs:=strSearch
and adding
CurrentDb.QueryDefs!qryFindName!prm_strSearch = OpenArgs
to Form_Open in the Form_frmSelectRecord module.
With every option, the parameter pop-up appears! HELP!!!
Must I use object variables with parameters? Must I requery after setting
the parameter in Form_Open? WHAT am I doing WRONG?!?