Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • 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!

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

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I've gotten solutions within a day - it saved a lot of time and actually got me one ATTABOY from my boss..."

Geography

Where in the world do Tek-Tips members come from?

Get the textbox value and use in Update Query using MacroHelpful Member! 

ctopia88 (IS/IT--Management)
31 Jul 12 9:46
Hi,

I have an update query wherein it will change the value of a certain column in the database as long as it will satisfy a certain value. The value will come from the current open form.

here is the flow if the events:
Open the form which has record in it, there is a
button that upon pressing will call a macro and the macro will call the update query. The update query's value is dependent on the form's textbox.

I am using this code in the update query "[FORMS]![F1]![CASE_ID]" where F1 is the name of the form and CASE_ID is the name of the textbox.

It is not working for it always pops a window that shows "[FORMS]![F1]![CASE_ID]" as a message and a textbox the requires user input. If I put the value of the case id, then it starts to update.

I want it to be automated. That when I press the buton, it will automatically pick the value of the CASE_ID textbox and update the database.

Please help!

Thanks,

SkipVought (Programmer)
31 Jul 12 9:49
hi,

...and your code?

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

ctopia88 (IS/IT--Management)
1 Aug 12 5:36
Hi,

here's my code for pressing the button:

Private Sub Closure_btn_Click()
Me.CSTATUS_Cmb.Value = "CLOSED"
DoCmd.RunMacro "UPDATESTATUS", , ""
End Sub

That is because I am calling the macro named "UPDATESTATUS"

LA
dhookom (Programmer)
1 Aug 12 8:53
What is the SQL view of the query?

Duane
Hook'D on Access
MS Access MVP

ctopia88 (IS/IT--Management)
2 Aug 12 8:07
Hi,

this is the SQL of the query:

UPDATE PHONE_DATA SET PHONE_DATA.CASE_STATUS = "CLOSED"
WHERE (((PHONE_DATA.LINKED_CID)=[FORMS]![F1]![CASE_ID]));


Please bear with me for I am new for this. I believe my query is wrong.

All I want to do is when the user press a button in the form, the value in the textbox named "CASE_ID" should be carried on to the query. The query will update all the records if the textbox value is equal to the value under the "LINKED_CID" column. Those that are equal, the "CASE_STATUS" value will be changed into "CLOSED".

Thanks,
Helpful Member!  dhookom (Programmer)
2 Aug 12 9:55
I would use code to run a SQL statement:

CODE

Dim strSQL as String
strSQL = "UPDATE PHONE_DATA SET PHONE_DATA.CASE_STATUS = 'CLOSED' " & _
    "WHERE LINKED_CID = " & Me.[CASE_ID]
CurrentDb.Execute strSQL, dbFailOnerror 
If CASE_ID is text, try:

CODE

Dim strSQL as String
strSQL = "UPDATE PHONE_DATA SET PHONE_DATA.CASE_STATUS = 'CLOSED' " & _
    "WHERE LINKED_CID = """ & Me.[CASE_ID] & """"
CurrentDb.Execute strSQL, dbFailOnerror 

Duane
Hook'D on Access
MS Access MVP

ctopia88 (IS/IT--Management)
6 Aug 12 6:39
thanks dhookom, the second one works :)

Reply To This Thread

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

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

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

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close