473,396 Members | 1,866 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

DoCmd.OpenQuery not working

294 256MB
I am trying to run this code/query:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenQuery "ForfeitVestingDateUpdateQry"
The query updates some fields in a table based on a date comparison. (whether or not the date the user entered is > than a date in the table.)

When I run the query from design mode (the red "!"), it works. When I try to run it via this method, it does not work.

The ONLY thing I can think of is that I am passing a parameter to it via a control on a subform in an if, then, else.
Expand|Select|Wrap|Line Numbers
  1. If([AwardTbl]![VestingDate]>Date(),[Forms]![AstProfileFrm]![AstProfileAwardFrm].[Form]![SepDateTxt],[AwardTbl]![VestingDate])
These are the 2 dates I am comparing. [AwardTbl]![AwardDate] and [Forms]![AstProfileFrm]![AstProfileAwardFrm].[Form]![SepDateTxt].

In VBA, I captured the value of SepDateTxt, and in debug mode it was correct. Also, like previously stated, it runs fine when ran manually.

Is this an issue with passing in a parameter or am I just doing something completely wrong? I cannot figure out why it won't work.

Edit: I tried the
Expand|Select|Wrap|Line Numbers
  1. db.Execute
method, and it threw an error saying "Too few parameters, expected 2". One parameter is the EmployeeID coming off of the parent form, and the other is the Date field SepDateTxt.

I tested the validity of both of them, via

Expand|Select|Wrap|Line Numbers
  1. Dim EmpID As Long
  2. Dim SepDate As Date
  3.  
  4. EmpID = Me.Parent!EmployeeID
  5. SepDate = Me!SepDateTxt
and they both had the correct values.
May 13 '14 #1
3 3162
zmbd
5,501 Expert Mod 4TB
mcupito

Would mind posting the full SQL, or is it just terribly long?

(^_^)
May 13 '14 #2
mcupito
294 256MB
Sure.

Expand|Select|Wrap|Line Numbers
  1. UPDATE AwardTbl
  2. INNER JOIN AssociateTbl ON AwardTbl.EmployeeID = AssociateTbl.EmployeeID
  3. SET 
  4. AwardTbl.ForfeitedUnits = [AwardTbl]![AwardUnits], AwardTbl.SpecialVestedUnits = 0,
  5.  AwardTbl.ForfeitDate = Date(),
  6.  AwardTbl.ForfeitNAV = Format(DateAdd("s",-1,DateAdd("q",DateDiff("q","1/1/1900",Date()),"1/1/1900")),"Short Date"),
  7.  AwardTbl.RepayUnits = [AwardTbl]![PaidOutUnits], AwardTbl.VestingDate = IIf([AwardTbl]![VestingDate]>Date(),[Forms]![AstProfileAwardFrm]![SepDateTxt],[AwardTbl]![VestingDate])
  8. WHERE (((AwardTbl.EmployeeID)=[Forms]![AstProfileFrm]![EmployeeID])
  9.        AND ((AwardTbl.AwardDate)>Date()));
I still can't figure out how to format that control on the subform if that's what is causing the error.

The field I am trying to refer to has a control source of a field in the query that supplies the data for that form. I'm not sure if that has anything to do with it. It's control source name is SeparationDate (I tried to put that in the query also and it didn't work.)
May 14 '14 #3
mcupito
294 256MB
I took off RecordLocks and now it works. Very interesting.

Thanks for your assistance, zmbd, as always!
May 14 '14 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: jj | last post by:
I've got a form button that fires off 3 queries but if the first query returns an error, I don't want the other two queries to happen. Example: first query runs an insert from a linked table but...
1
by: tina | last post by:
Hello, I would really appreciate some help. I am still learning VBA and I feel like my brain is fried already. Below I am trying to run a query and do a loop. I actually get the data set but...
2
by: Tyson | last post by:
I have got this little piece of code that fires on exit of a text box. It run's my query perfectly based of my form input. But I don't know how to bring result in my query back to a text box on my...
1
by: DD | last post by:
I have a form and in the OnOpen Event i have the following DoCmd.OpenQuery "qryUpDatePayment" This creates an error,,however i need to update the qry when i open the form this is only occuring...
2
by: technocraze | last post by:
Hi community experts, May I know is it possible to display an error message or not opening a form or query when users provide with the wrong inputs in the DoCmd.OpenForm and DoCmd.OpenQuery...
7
by: Kosmos | last post by:
I should probably know this, but I have a query that I'm opening with VBA: DoCmd.OpenQuery "SortTableClientCN_ASC", acViewNormal, acEdit the query is the following: SELECT tblClientCN.ClientCN...
1
by: VBANewbie | last post by:
Hi all, Just a small question concerning the memory problem. Whenever we open an existing query inside a module: DoCmd.OpenQuery ("Query Name") Do we have to put another command line to...
10
by: teddysnips | last post by:
My clients have asked me to maintain a database that was developed in- house. It's pretty good, considering the developer isn't a "programmer". The first thing they want me to do is to split it...
2
by: Ceylon | last post by:
Hi, 1. I am doing a simple timesheet model in Access. When i click on Review button with given dates, this will run a query to find the Username, Start Date, Break Start time, Break End Time and...
2
by: ncsthbell | last post by:
Using MS Access 2007. I built a form that has a combo box of lists of 'actions' (cmboActions). This form also has a button to click that I want to run a query and display the results in datasheet...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.