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
Solved

How do I pass a Value from a form txtBox to a SQL ADODC RecordSource statement on the same form.

Posted on 2003-10-24
10
191 Views
Last Modified: 2010-05-03
I am somewhat new to VB6.  Here is my quandary.  I have a form with a DataGrid on it, I have a field with a PASSED value from another form, that is PASSED on form load.

I need to have the SQL statement in the ADODC, RecordSource select the record from the database based on the value from the form field (that was passed).

select Est_No,Est_Notes,Est_Opening_Date,Est_Opening_Location,Est_Opening_Time,Est_Value from tblEstInfo Where Est_No = [this is where I need it to select the record based on the PASSED value in the txtEstNo text box]

Any help would be greatly appreciated????

Thanks in ADVANCE

Charlie
0
Comment
Question by:CMHamrick
10 Comments
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 500 total points
ID: 9617227
select Est_No,Est_Notes,Est_Opening_Date,Est_Opening_Location,Est_Opening_Time,Est_Value from tblEstInfo Where Est_No ='" & txtEstNo.Text & "'"
0
 

Author Comment

by:CMHamrick
ID: 9617268
Syntax error on above???
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 9617332
How about:

...... Where Est_No =" & Chr$(34) & txtEstNo.Text & Chr$(34)
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

Author Comment

by:CMHamrick
ID: 9617394
Does not work :(

The SQL statement goes in the DataGrid/ADODC/RecordSource/CommandText box...
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 9617434
Whats the value in the txtEstNo Textbox?
0
 

Author Comment

by:CMHamrick
ID: 9617437
03-01  or 03-02  or 03-03, etc.
0
 

Author Comment

by:CMHamrick
ID: 9617444
Try my AIM for instant response....   cmhamrick
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9617636
did you fully qualify text box name?
I mean frmWhatEver.txtEstNo.text

or are you trying to put that sentence in the property of datagrid?
If last one, you cannot do it that way, at least not at design-time but at run-time
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 9617760
>>Syntax error on above???
Does not work :(<<
Does not help anyone identify the problem.  In the first case, what was the error, in the second case was there 1. An error occured, if so which?
2. Not the right results.
3. Smoke coming out of the monitor

>>Try my AIM for instant response....   cmhamrick <<
This is not encouraged here at EE.  We are all here to share ideas.

Having said that, can you post you existing code and what you are trying to achieve.

Anthony
0
 
LVL 1

Expert Comment

by:MN_Dave
ID: 9618250
When I have a problem like this I will put the sql statement into a string variable so that I can see that is looks the way I think it will...

Dim sqlStr as string

sqlstr = "select Est_No,Est_Notes,Est_Opening_Date,Est_Opening_Location,Est_Opening_Time,Est_Value from tblEstInfo Where Est_No ='" & txtEstNo.Text & "'"

After this statement I will look at the value of sqlstr, which should be something like:
select Est_No,Est_Notes,Est_Opening_Date,Est_Opening_Location,Est_Opening_Time,Est_Value from tblEstInfo Where Est_No ='03-01'

I have found this to be helpful in identifying minor syntax errors.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

839 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