Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 17th, 2006, 03:04 AM
Friend of Wrox
 
Join Date: Oct 2006
Location: Northampton, Northants, United Kingdom.
Posts: 115
Thanks: 0
Thanked 0 Times in 0 Posts
Default The OpenForm action was canceled

You used a method of the DoCmd object to carry out an action in Visual Basic, but then clicked Cancel in a dialog box.

stLinkCriteria = "[Employee_Courses].[COURSE_DATE]='" & Me.TrainingDate.Value & "' AND [LKPTrainingType].[TrainingTypeDesc]='" & Me.txtTrainingType & "' AND [SiteCode]='" & Forms!frmProperty!SiteCodeCombo & "' AND [BlockNo]='" & Forms!frmProperty!BlockCodeCombo & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

The value of stLinkCriteria is as follows:

[Employee_Courses].[COURSE_DATE]='22/03/2006' AND [LKPTrainingType].[TrainingTypeDesc]='Fire Induction' AND [SiteCode]='21800' AND [BlockNo]='01'

I have tried a variation (below) which works, but cannot see what's going on with the date.

[LKPTrainingType].[TrainingTypeDesc]='Fire Induction' AND [SiteCode]='21800' AND [BlockNo]='01'

Any help appreciated...

Regards,

Sean Anderson
__________________
Regards,

Sean Anderson
Reply With Quote
  #2 (permalink)  
Old October 17th, 2006, 03:12 AM
Friend of Wrox
 
Join Date: Oct 2006
Location: Northampton, Northants, United Kingdom.
Posts: 115
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Additionally, I have tried with no success, to reformat the date (as below) and have also tried each with '#' surrounding the date.

dd/mm/yyyy
mm/dd/yyyy
yyyy-mm-dd

Regards,

Sean Anderson
Reply With Quote
  #3 (permalink)  
Old October 17th, 2006, 06:47 AM
Friend of Wrox
 
Join Date: Oct 2006
Location: Northampton, Northants, United Kingdom.
Posts: 115
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Terribly frustrating that this was something so glaringly obvious.

Changing the date format so that the line now reads as follows did the trick.

stLinkCriteria = "[Employee_Courses].[COURSE_DATE]=#" & Format(Me.TrainingDate.Value, "mm/dd/yyyy") & "# AND [LKPTrainingType].[TrainingTypeDesc]='" & Me.txtTrainingType & "' AND [SiteCode]='" & Forms!frmProperty!SiteCodeCombo & "' AND [BlockNo]='" & Forms!frmProperty!BlockCodeCombo & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Resulting in stLinkCriteria being equal to the following.

[Employee_Courses].[COURSE_DATE]=#03/22/2006# AND [LKPTrainingType].[TrainingTypeDesc]='Fire Induction' AND [SiteCode]='21800' AND [BlockNo]='01'

Regards,

Sean Anderson
Reply With Quote
  #4 (permalink)  
Old October 18th, 2006, 12:34 PM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Alternatively, you can place the criteria for the date directly in the query designer. In the first Criteria cell under the COURSE_DATE column, put:

[Forms]![frmMyFormName].[TrainingDate]

In the TrainingTypeDesc column put:

[Forms]![frmMyFormName].[txtTraningType]

etc.

This will allow you to just have this code on your button:

'----------------------
Dim stDocName As String
stDocName = "rptMyReportName"
DoCmd.OpenForm stDocName
'----------------------

The downside is that the query can only be used with that report when the form is opened. Ideally you would have some sort of check on the form to make sure all the values had been selected.

HTH




mmcdonal
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Request action on change and get no action. Help crussell Ajax 0 September 12th, 2007 11:11 AM
"The OpenForm command was canceled" Bob Pierce Access 2 April 24th, 2007 05:07 AM
Error 2001 You canceled the previous operation RayL Access VBA 3 December 8th, 2006 03:00 PM
"you canceled the previous operation" error Totenkopf Access VBA 2 June 14th, 2006 02:48 PM
you canceled the previous operation lizhaskin Access 1 July 19th, 2005 12:36 PM



All times are GMT -4. The time now is 10:23 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.