I'm somewhat new to Access, and have no VB experience at all (except for modifying existing code where obvious).
I built a data entry form that works fine. Typically, a client will call in and the user has to find his record to add or modify existing data. Originally, I built the form based on a query with an input criteria for the last name and first name. The Last_Name critera is Like [What is Last Name?]&"*" so that partial names will work. The query also includes a similar criteria for first name.
Then, I needed to enable the search by Client_ID. I built a new query for this, because I didn't want the user to have to see the pop-up dialogs for Name. The problem with this approach is that I had to duplicate the existing data entry form based on the second query instead of the first. I don't want to have to maintain two identical forms.
I decided to try an unbound search form with these three fields, so that I could use a single query and form. It almost works. The query works fine when called directly, but when I use the search form to call the data entry form based upon the query, it goes awry.
My query has the following criteria:
Client_ID: [Forms]![search_Form]![S_ID]
Then, on a separate criteria line (meaning OR)
Last_Name: Like IIf(IsNull([forms]![Search_Form]![S_Last]),Null,[Forms]![Search_Form]![S_Last] & "*")
AND
First_Name: Like ([Forms]![Search_Form]![S_First] & "*")
My thinking was that if the last name from the Search form is left blank (Null), it will return nothing based on the NAME line. It works fine when I query directly. If I input name data, it only returns appropriate names records, and if I input a Client_ID, it only returns that Client_ID. However, if I use the Search_Form, only the NAME criteria works. If I input a Client_ID, it returns all names instead of none.
My search form consists only of these three fields and they are unbound. I tried the query with and without the field parameters specified (name fields=text, Client_ID field = long integer) and it made no difference.
Can anyone help?
I built a data entry form that works fine. Typically, a client will call in and the user has to find his record to add or modify existing data. Originally, I built the form based on a query with an input criteria for the last name and first name. The Last_Name critera is Like [What is Last Name?]&"*" so that partial names will work. The query also includes a similar criteria for first name.
Then, I needed to enable the search by Client_ID. I built a new query for this, because I didn't want the user to have to see the pop-up dialogs for Name. The problem with this approach is that I had to duplicate the existing data entry form based on the second query instead of the first. I don't want to have to maintain two identical forms.
I decided to try an unbound search form with these three fields, so that I could use a single query and form. It almost works. The query works fine when called directly, but when I use the search form to call the data entry form based upon the query, it goes awry.
My query has the following criteria:
Client_ID: [Forms]![search_Form]![S_ID]
Then, on a separate criteria line (meaning OR)
Last_Name: Like IIf(IsNull([forms]![Search_Form]![S_Last]),Null,[Forms]![Search_Form]![S_Last] & "*")
AND
First_Name: Like ([Forms]![Search_Form]![S_First] & "*")
My thinking was that if the last name from the Search form is left blank (Null), it will return nothing based on the NAME line. It works fine when I query directly. If I input name data, it only returns appropriate names records, and if I input a Client_ID, it only returns that Client_ID. However, if I use the Search_Form, only the NAME criteria works. If I input a Client_ID, it returns all names instead of none.
My search form consists only of these three fields and they are unbound. I tried the query with and without the field parameters specified (name fields=text, Client_ID field = long integer) and it made no difference.
Can anyone help?
Comment