access VB says
"Too few parameters"
How do I write it?
Code:Dim empID2 As Long empID2 = Me.Parent.txtEmpID SQL2 = "SELECT [WOitems] FROM tblTimeClock WHERE EmpID = EmpID2"
SQL2 = "SELECT [WOitems] FROM tblTimeClock WHERE EmpID = " & CSTR( EmpID2 ) & " ; "
I guess I am unsure about how to refer to controls or fields from different areas and of course, apparently I don’t get the concatenation syntax at all. But help please!Doing it again![]()
You refer to them in the same way.I guess I am unsure about how to refer to controls or fields from different areas and of course, apparently I don’t get the concatenation syntax at all. But help please!
Isn't that what a dev do daily ? Just debug stuff and change it until it is fixed ?You refer to them in the same way.
Strings need to be surrounded with ' unless it has a ' in it, then I *think* """ would work instead.
Dates need # surrounding them and in mm/dd/yyyy or yyyy-mm-dd format
Numbers do not need anything.
Again for the umpteenth time, not just to you but to other members trying to concatenat, put the criteria into a string variable and Debug.Print that.
That should show you the errors, then just alter until you get it correct.
Thank you DonMan, I am very much a beginner but I have managed to accomplish some pretty good things. I really didn’t understand the explanation but I am learning. I really appreciate all the help you guys give me and I am definitely learning, but there is a lot to soak up.Re-read the article I referenced. It will tell you why you need to use concatenation at all. Or did you not understand my explanation?
Think of Access as having TWO parts. The part that interacts with YOU and the part that interacts with your DATA. Your part is the User Interface (UI) and the data part is SQL. They are in TWO SEPARATE computer tasks. If you know Windows nomenclature, two PROCESSES. They each have their own memory. Therefore, the REASON for needing to concatenate stuff into a string is when you are doing something in the UI that has to interact with SQL, you need to prepare the SQL because SQL cannot see the UI except in certain very limited ways - and seeing variables isn't one of the exceptions.
Unfortunately that’s what I have to do, except for the debug.print. Not even sure how to do that. That sounds like it would help a lot.Isn't that what a dev do daily ? Just debug stuff and change it until it is fixed ?![]()
Unfortunately that’s what I have to do, except for the debug.print. Not even sure how to do that. That sounds like it would help a lot.![]()
Debug.Print "In My Code x = " & MyVariable_X
How do i run the code, by keeping the vba window open and click on the appropriate button on my form (or whatever else I do that runs code?)In your code add
Debug.Print "In My Code x = " & MyVariable_X
At an appropriate point after you think you have set the variable to something.
Then in the immediate window in the VBA editor (press Ctrl + G to bring it up), when your code runs you will see the result.
Heading to the link now to read. ThanksTo help with proper delimiters and concatenation
Get Filter from Controls, CSQL, and Combine Multiple Filters
If you follow my threads, I try to demonstrate how to write code that is flexible, generic, encapsulated, fault proof, and debuggable. My goal is always to try to write code once that can be re-used often and everywhere. I do this in functions, procedures, and class modules. This may require...www.access-programmers.co.uk
Just curious if you saw the link I posted earlier... I'd like to know if it was helpful or not (so I can update it). Cheers!Heading to the link now to read. Thanks
I am going there after I finish reading MajP’s post.Just curious if you saw the link I posted earlier... I'd like to know if it was helpful or not (so I can update it). Cheers!
Okay, thanks. I'm really interested in what you think of it.I am going there after I finish reading MajP’s post.
That's all over my head, where can I go to educate my self to read the code you posted and understand what I read?Heading to the link now to read. Thanks
Wow! I can now understand a "little" better, most of everything I read here is over my head and I just keep working until I accomplish the task, no matter how small. But your blog gives me insight as to why I am doing what needs to be done, and thus educating me. I have written a pretty extensive database app for work, and I am sure if I had more knowledge I could understand more and move at a faster, more error free pace.Have I shown you this yet?
How to build strings in VBA
I promised a member at UtterAcess that I will write a blog about how to build a string in VBA, particularly when constructing a SQL statemen...thedbguy.blogspot.com
Hi. Thanks for letting me know what you think. I'll try to make it even better next time. Good luck with your learning journey. Cheers!Wow! I can now understand a "little" better, most of everything I read here is over my head and I just keep working until I accomplish the task, no matter how small. But your blog gives me insight as to why I am doing what needs to be done, and thus educating me. I have written a pretty extensive database app for work, and I am sure if I had more knowledge I could understand more and move at a faster, more error free pace.
Thank you much and let me know if you have any other lessons for beginner programmer's like myself.