Hi,
I am in the process of making a stock control system. One part of the database is customer details.
I have made a form so that we can search through the customer data. We want to search for records by entering First Name AND/OR SURNAME.
I have made the form with a list box in it that uses a query to search through the customer details table depending on values in a 'first name' and 'surname' text boxes. The code for the list box update/onchange looks like this -
Private Sub txtSearch_Change()
Dim vSearchString As String
vSearchString = txtSearch.Text
txtSearch2.Value = vSearchString
Me.List30.Requery
End Sub
Private Sub txtSearch3_Change()
Dim vSearchString As String
vSearchString = txtSearch3.Text
txtSearch4.Value = vSearchString
Me.List30.Requery
End Sub
There is therefore two crtieria in my query - one for first name -
Like "*" & [Forms]![CustomerSearch]![txtSearch2] & "*"
and one for surname -
Like "*" & [Forms]![CustomerSearch]![txtSearch4] & "*".
Now, i have three questions.
1) Firstly, how can i make it so that i can use Null values in one of the text boxes so i therefore can return just surname or just first name if i wish. Or is this to do with the query criteria not allowing null values?
2) secondly, how can i clear/reset everything so that whenever i open the form the text boxes are empty and the query has not searched anything.
3) I want to take the Customer ID number from that search (when double-clicked) and insert it into a text box in another form. What would the code for the event procedure be if the other form was called "Customer Purchases" and the text box was called "CustomerID".
Here is a copy of part of the Database, with the relevant parts.
PLEASE NOTE: THE DETAILS IN THIS EXAMPLE ARE NOT REAL. THE CUSTOMERS DO NOT REALLY EXIST.
http://www.access-programmers.co.uk/forums/attachment.php?attachmentid=15250&stc=1&d=1161624371
Carpet Stock Control.zip
Please take into consideration that im a bit of a noob with this stuff so be gentle with your answers.
Thanks in advance for anyone's help, James
I am in the process of making a stock control system. One part of the database is customer details.
I have made a form so that we can search through the customer data. We want to search for records by entering First Name AND/OR SURNAME.
I have made the form with a list box in it that uses a query to search through the customer details table depending on values in a 'first name' and 'surname' text boxes. The code for the list box update/onchange looks like this -
Private Sub txtSearch_Change()
Dim vSearchString As String
vSearchString = txtSearch.Text
txtSearch2.Value = vSearchString
Me.List30.Requery
End Sub
Private Sub txtSearch3_Change()
Dim vSearchString As String
vSearchString = txtSearch3.Text
txtSearch4.Value = vSearchString
Me.List30.Requery
End Sub
There is therefore two crtieria in my query - one for first name -
Like "*" & [Forms]![CustomerSearch]![txtSearch2] & "*"
and one for surname -
Like "*" & [Forms]![CustomerSearch]![txtSearch4] & "*".
Now, i have three questions.
1) Firstly, how can i make it so that i can use Null values in one of the text boxes so i therefore can return just surname or just first name if i wish. Or is this to do with the query criteria not allowing null values?
2) secondly, how can i clear/reset everything so that whenever i open the form the text boxes are empty and the query has not searched anything.
3) I want to take the Customer ID number from that search (when double-clicked) and insert it into a text box in another form. What would the code for the event procedure be if the other form was called "Customer Purchases" and the text box was called "CustomerID".
Here is a copy of part of the Database, with the relevant parts.
PLEASE NOTE: THE DETAILS IN THIS EXAMPLE ARE NOT REAL. THE CUSTOMERS DO NOT REALLY EXIST.
http://www.access-programmers.co.uk/forums/attachment.php?attachmentid=15250&stc=1&d=1161624371
Carpet Stock Control.zip
Please take into consideration that im a bit of a noob with this stuff so be gentle with your answers.
Thanks in advance for anyone's help, James
Attachments
Last edited: