Possible coding issue with ID No. Search Forms

JewliaB

Registered User.
Local time
Today, 11:54
Joined
Sep 11, 2008
Messages
27
Okay, I don't know if there's a better way to do this. If so please explain how, but otherwise, I need to fix my ?coding? I think? I'm creating this database to track my volunteers' information and to track their hours. I have this set up as two seperate, but intertwined databases. One database has all of the volunteer contact information and assigns them an ID No. In the second database, I have a form where the user enters the ID No. of the volunteer and then enters the date and start and end times of the volunteer hours. For this to work, the user needs to be able to look up the volunteer's ID No. and verify that it is the correct one. I already have a search installed in the first form, where the data is entered. I was trying to install a similar function. I created a second form that is like the data entry form, but will not be editable and only contains some base information, such as the volunteer's start date and type code. This way they can look up the name and verify the identify. Then they can use the ID No. In the original search, you have the volunteer information form open and you click the search button. This brings up a seperate form where you set your perameters and search criteria (i.e. I would like to search "LastName" for "Smith"). It then filters the form to display only the results that fit the perameters. I want this to do the same thing except I need to be in the hours entering form and click the search. It needs to open up a new form (IDInformationForm) and filter this form. I attempted to code it as follows. Did I make an error in my coding? Is there a better way to do this?

My database and form names are as follows.

Databases
*VolunteerDatabase
*Hours Database

Forms
*VolunteerInfomation (Where volunteer data is entered)
*SearchForm (Search Form for VolunteerInformation form. Works correctly).
*HoursInformation (Where hours are entered)
*IDSearchForm (Search Form for the ID Number of volunteer).
*VolunteerIDNumberLookUp (Form that I would like to have brought up with the volunteer name, ID No., and a few basic key facts.)

Private Sub cmdSearchID_Click()
If Len(cboSearchField) = 0 Or IsNull(cboSearchField) = True Then
MsgBox "You must select a field to search."
ElseIf Len(txtSearchString) = 0 Or IsNull(txtSearchString) = True Then
MsgBox "You must enter a search string."
Else
'Open VolunteerIDLookUp
DoCmd.OpenForm acForm, "VolunteerIDNumberLookUp"
'Generate search criteria
GCriteria = cboSearchField.Value & " LIKE '*" & txtSearchString & "*'"
'Filter VolunteerIDNumber LookUp based on search criteria
Form_VolunteerIDNumberLookUp.RecordSource = "select * from VolunteerDatabase where " & GCriteria
Form_VolunteerIDNumberLookUp.Caption = "VolunteerDatabase (" & cboSearchField.Value & " contains '*" & txtSearchString & "*')"
'Close SearchForm
DoCmd.Close acForm, "IDSearchForm"
MsgBox "Results have been filtered."
End If

I can't post the database because it's too large.

Thank you all in advance.
 
Last edited:
I totally forgot about zip files. Silly me. Here is the sample database.

I keep receiving runtime error 13 type mismatch
 

Attachments

Last edited:
Wrong syntax; try

DoCmd.OpenForm "VolunteerIDNumberLookUp"
 

Users who are viewing this thread

Back
Top Bottom