• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 200
  • Last Modified:

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

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
CMHamrick
Asked:
CMHamrick
1 Solution
 
vinnyd79Commented:
select Est_No,Est_Notes,Est_Opening_Date,Est_Opening_Location,Est_Opening_Time,Est_Value from tblEstInfo Where Est_No ='" & txtEstNo.Text & "'"
0
 
CMHamrickAuthor Commented:
Syntax error on above???
0
 
vinnyd79Commented:
How about:

...... Where Est_No =" & Chr$(34) & txtEstNo.Text & Chr$(34)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
CMHamrickAuthor Commented:
Does not work :(

The SQL statement goes in the DataGrid/ADODC/RecordSource/CommandText box...
0
 
vinnyd79Commented:
Whats the value in the txtEstNo Textbox?
0
 
CMHamrickAuthor Commented:
03-01  or 03-02  or 03-03, etc.
0
 
CMHamrickAuthor Commented:
Try my AIM for instant response....   cmhamrick
0
 
Richie_SimonettiIT OperationsCommented:
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
 
Anthony PerkinsCommented:
>>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
 
MN_DaveCommented:
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

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now