By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,152 Members | 2,576 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,152 IT Pros & Developers. It's quick & easy.

Using VBA SQL returned values

100+
P: 116
so my problem is I want to use the values returned from the below SQL to populate textboxes etc. on my form. Is there a way to assign these values(VALUE1,VALUE2) to variables?

Thanks,
Eric

Expand|Select|Wrap|Line Numbers
  1.  Dim strSQL As String
  2.  
  3.       strSQL = "SELECT A.VALUE1, A.VALUE2 FROM tblWORK_DETAIL A WHERE    A.BUILD_NAME='" & Me.cboBUILD_NAME.Value & " " & _
  4.                  "AND A.WORK_DATE= (SELECT MAX(B.WORK_DATE)FROM tblWORK_DETAIL B" & _
  5.                  "WHERE A.BUILD_NAME=B.BUILD_NAME" & _
  6.                  "AND A.WORK_DATE=B.WORK_DATE"
  7.  
  8.  DoCmd.RunSQL.strSQL
  9.  
  10.  
Dec 12 '07 #1
Share this Question
Share on Google+
3 Replies


NeoPa
Expert Mod 15k+
P: 31,616
Typically, you would set the Record Source of the form to the SQL you require then all controls on the form can be bound to the fields returned.
The Record Source can be changed dynamically on opening the form, or a filter can be applied (less design work) at invokation time of the form.
Dec 12 '07 #2

100+
P: 116
Typically, you would set the Record Source of the form to the SQL you require then all controls on the form can be bound to the fields returned.
The Record Source can be changed dynamically on opening the form, or a filter can be applied (less design work) at invokation time of the form.

Thanks NeoPa i think that should work.

Eric
Dec 12 '07 #3

NeoPa
Expert Mod 15k+
P: 31,616
No worries Eric.
Let us know how you get on with it :)
Dec 12 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.