Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Button in VB6 and sql statement to Access XL

Posted on 2003-03-03
3
Medium Priority
?
224 Views
Last Modified: 2012-08-14
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
0
Comment
Question by:bartsan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Expert Comment

by:mypcguy
ID: 8060947
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.
0
 
LVL 26

Accepted Solution

by:
Alan Warren earned 80 total points
ID: 8061299
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.


alan
0
 

Author Comment

by:bartsan
ID: 8068103
Alan,

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
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question