sammyquest85
asked on
Finding records in a DGrid using parameters from access table
I am a kenyan who is new in vb, and i have had this particular problem. I want to connect to an access table with parameters and allow the user to find records by entering His/her paramerters from a form.
Just how can I do that?
(SOME CODE MIGHT HELP)
NOTE: I AM USING ADO CODE.
Just how can I do that?
(SOME CODE MIGHT HELP)
NOTE: I AM USING ADO CODE.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi sammyquest85,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:
Accept paulll's comment(s) as an answer.
sammyquest85, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you. DO NOT accept this comment as an answer.
==========
DanRollins -- EE database cleanup volunteer
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:
Accept paulll's comment(s) as an answer.
sammyquest85, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you. DO NOT accept this comment as an answer.
==========
DanRollins -- EE database cleanup volunteer
per recommendation
SpideyMod
Community Support Moderator @Experts Exchange
SpideyMod
Community Support Moderator @Experts Exchange
Example:
A form that has searching on customer, city and state.
The form would have text boxes TxtCustomer, TxtCity and TxtState.
When user presses an OK button to do the search, use the following code.
Dim SqlString as String, ValType as String, temp as String
SqlString = "SELECT * FROM TableName WHERE Customer IS NOT NULL"
If Len(TxtCustomer) Then
temp = TxtCustomer
ValType = GetValType(temp)
SqlString = SqlString & " AND Customer ValType '" & TxtCustomer & "'"
End If
If Len(TxtCity) Then
temp = TxtCity
ValType = GetValType(temp)
SqlString = SqlString & " AND City ValType '" & TxtCity & "'"
End If
If Len(TxtState) Then
temp = TxtState
ValType = GetValType(temp)
SqlString = SqlString & " AND State ValType '" & TxtState & "'"
End If
You could also do date ranges using the "BETWEEN" reserved word for 2 text boxes.
Function GetValType(ByVal temp As String) As String
'You could use a check box with a value of 1 to do searches of "LIKE" and
'put your own percent signs before and after the values in the text box criteria
If Instr(temp, "%") Then
GetValType = "LIKE"
Else
GetValType = "="
End If
End Function