×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Enter Parameter once for multiple parameter queries

Enter Parameter once for multiple parameter queries

Enter Parameter once for multiple parameter queries

(OP)
Hi all, I created a command which runs an update query and an append query. Each query requires that the user enter an input. The input is the same for each query, but because it is two different queries, access prompts to enter the same number twice. Could someone show how to code so that i only have to enter once?

Private sub command29_click()

docmd.runsql "update table set field = [ENTER] where isnull(field)"

docmd.runsql "update table1 set field1=[  ]![  ]![  ]
where (([table1].[field2]=[ENTER]))

end sub

I am new so please help. In this case I want to make it so that [Enter] only has to be entered once.
Is there a way to prompt for a variable before running the SQL and then setting [Enter] to be equal to that variable!?!?!
Thanks for any response!!

RE: Enter Parameter once for multiple parameter queries

Hi Noel,

Get the input parameter from the user with your VB code, and then use this value in the query strings.  Like the following.

CODE

Private Sub Command0_click()

Dim strInput As String

strInput = InputBox("Please enter parameter")
DoCmd.RunSQL "update Transactions set Amount = " & strInput & _
             " where isnull(Amount)"
DoCmd.RunSQL "update Receipts set Checked = True" & _
             " where Receipts.Amount = " & strInput

End Sub
Hope this helps.  Cheers.

Yeasir Rahul

Principal, VoltSmith Technologies
www.voltsmith.com

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login



News


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close