Button in VB6 and sql statement to Access XL

Hi All,
I have an Access table and I would like to search for datas matching a certain input field in a Visual Basic 6 form.

Name of the table is A with a1 to a4 as the column names. I've created a data environment and within a command which has the following sql statement

SELECT a1, a2, a3 FROM a WHERE (a2 LIKE inputField)

Unfortunately do I have problems to connect this to a button in VB.

It would be ideal if the result could be stored in another table but I do not know how.

Whenever I run the above command with an exact value like for instance 'test' everything is okay but it doesn't get the variable form the input field. Any idea where the bug is?

Thank you for your support

Kind regards Andreas
Who is Participating?
Alan WarrenConnect With a Mentor Commented:
dim sql as string
sql = "SELECT a1, a2, a3 FROM a WHERE a.a2 LIKE " & inputField.value

then set the DataEnvironment to use sql as it's datasource.

I'm not sure what you're doing between VB and Access, but make sure your syntax is correct - ";" at the end, quotes in the right places, things like that.
bartsanAuthor Commented:

thanks for the answer.

What I miss now is the next step, connecting it to the data environment. I've used the properties window to add tables or sql statements to the commands but with a variable is this probably impossible. I am new to VB and the MS world therefore these stupid questions.

My intention is to use the input field value and get a result in a small pop up window where the user can choose a specific record.

Any additional comments?

Thanky you for your help

Cheers Andreas
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.