Just a simple question

11-04-2004, 02:06 AM
Hi, I'm new in VB programming. Now I am working on a project to make a database application. I use Microsoft Access and VB6. One of the functions that I need to create is the search function which is used to find a record or a list of records according to the user's specification.
I've tried to use SQL statements and ADO control but it won't work. The codes are:

Private Sub cmdStart_Click()

datScrhMaint.RecordSource = "Select * from Maintenance where Date = txtDate.Text "
End Sub

The "txtDate.Text" is the user's input.

My question is: Can I use the user's input data as a parameter? How?

Thanks in advance.

11-04-2004, 03:15 AM

The SQL string would look like:

"Select * from Maintenance where [Date] = #"& txtDate.Text & "#"

For the rest try to avoid using DataControl.
Please have a look at the Beginner's ADO tutorial in the FAQ section


11-04-2004, 05:37 AM
Hello Raine,
I agree with Shurik12,
I suggest you go first with the basics. Its a good jumpstart.
Welcome :)

11-06-2004, 10:04 AM
If Maintenance is the defined datasource for the report (in design view it is already assigned to this datasource), all you want to do is send a where clause or filter string to your report. You can do this via the DoCmd.OpenReport method..you can pass a string command as the last parameter of this call that specifys your filter condition.

Good luck with those tutorials.

11-07-2004, 07:18 PM
OK, thank you very much everyone :)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum