i need to get my criteria from the vba code, can this be done

  • Thread starter trevorC via AccessMonster.com
  • Start date
T

trevorC via AccessMonster.com

I'm trying to run a query to update a table, the criteria for one of the
fields in the query comes from an input box via the VBA code for the form.
Can I use this variable for the query criteria ?.
Or do I need to assign this to a unbount text box on my form and use that
text box for the criteria ?
 
K

Ken Snell MVP

Unless you're building the SQL statement in code for the query that you're
going to run, then yes assign the value from the InputBox to a hidden
textbox on your form and use the form's textbox in the query's criterion
clause.
 
T

trevorC via AccessMonster.com

Ken, Is there an easy way to convert the query SQL into VBA code.
this is my sample code. i guess the main point is the where clause.
But how do i convert this to VBA, the syntax is my main problem for this.

UPDATE GAMREP SET GAMREP.print = True
WHERE (((GAMREP.[Customer Tech #])=[Forms]![Label Selection1]![Console number
check]));
 
K

Ken Snell MVP

Assuming you want to concatenate the value from the form's textbox into the
query (Watch that I didn't add or delete important spaces in field or
control names):

If Console number check is a number:

Dim strSQL As String
strSQL = "UPDATE GAMREP SET GAMREP.print = True" & _
" WHERE (((GAMREP.[Customer Tech #])=" & _
[Forms]![Label Selection1]![Console number check] & "));"


If Console number check is a text string:

Dim strSQL As String
strSQL = "UPDATE GAMREP SET GAMREP.print = True" & _
" WHERE (((GAMREP.[Customer Tech #])='" & _
[Forms]![Label Selection1]![Console number check] & "'));"
 
T

trevorC via AccessMonster.com

Hi, I use a check box for the select to print feature, which of the previous
statments do i use for a check box; text or numeric?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top