×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

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

*Tek-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

Help to get syntax correct

Help to get syntax correct

Help to get syntax correct

(OP)
Hello, spent too many hours at the screen today.

I wonder if someone could help.

I have the line:

CODE -->

CurrentDb.Execute "Update [tbl_Invoice] SET [Inv_Scan_FilestoreID] = '" & Me.[txt_Gemini_Prop_Deduct_Lan_Ref] & "' WHERE Inv_ID = " & Me.txt_100 

I want to replace the part where I refer to the textbox: Me.[txt_Gemini_Prop_Deduct_Lan_Ref] with a Variable I have defined as: fileStoreID

I'd much appreciate if someone could provide the correct line. Thank you very much Mark

RE: Help to get syntax correct

It's been quite a few years since I messed with Access. If fileStoreID is a number, then you don't need the single quotes around it. If you haven't looked at your syntax using debug, then I suggest you try it.

Modify your code to look like this:
Dim strUp as string
Dim fileStoreID as long

stop
fileStoreID = 123
strUp = "Update [tbl_Invoice] SET [Inv_Scan_FilestoreID] = " & fileStoreID & " WHERE Inv_ID = " & Me.txt_100

When your code executes the stop statement, the code will stop at that statement and the debug Immediate window will appear. Press the F8 button to step through your code 1 line at a time. When you step pass the strUp=... line, type ?strUp in debug's Immediate window. It will display the contents of strUp. This is a simple way to check your syntax. Note, press F5 to execute your code to the end or to the next stop statement.

RE: Help to get syntax correct

(OP)
Mnay thanks Mark

RE: Help to get syntax correct

Over all, it is a good idea (IMHO) to assign your statement to a variable before you execute it, so you can see what you are doing.

CODE

Dim strUp as string
Dim fileStoreID as long

stop
fileStoreID = 123
strUp = "Update [tbl_Invoice] SET [Inv_Scan_FilestoreID] = " & fileStoreID & " WHERE Inv_ID = " & Me.txt_100
Debug.Print strUp
CurrentDb.Execute strUp 


---- Andy

There is a great need for a sarcasm font.

RE: Help to get syntax correct

Andy,
I whole heartedly agree. Plus, I wouldn't settle for txt_100. I couldn't sleep at night.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016

RE: Help to get syntax correct

On one hand we have nice, fully descriptive txt_Gemini_Prop_Deduct_Lan_Ref smile A little long for my teste, but nothing that Ctrl-Space wouldn't fix (read: type), and on the other hand we have cryptic txt_100 sad


---- Andy

There is a great need for a sarcasm font.

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 Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

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! Already a Member? Login

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