473,395 Members | 1,756 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,395 software developers and data experts.

Access 2007 / VBA subform syntax for criteria question

I'm working in Access 2007 and coming to something that's always caused me problems. I have a form titled frmUsers. There are 3 subforms that list exercise dates and exercise types for each user. My goal is for whenever you click on any of the subform listings that a report will pull up with that date's activity.

Main Form = frmUsers
Subform item = Workout_List
Subform name = frmList_Workout
OnClick field = Workout_Date in the subform
Other criteria field = UserName in the subform

Expand|Select|Wrap|Line Numbers
  1. Private Sub Workout_Date_Click()
  2. DoCmd.OpenReport "rptWorkout_Header", acViewPreview, , [Workout_Date] = Forms.frmUsers.Workout_List.Form.Workout_Date And  [UserName] = Forms.frmUsers.Workout_List.Form.UserName
  3. End Sub
What's happening is it doesn't appear to be using the Where criteria on anything, I'm getting the full rptWorkout_Header report.

What should I be doing to get this to work?


Updated --- In doing some more searching for assistance, I found the answer to treat the WHERE statement as I would any other code situation minus the WHERE statement. I've since solved this.
Jul 25 '10 #1
2 1963
patjones
931 Expert 512MB
You should be submitting the filter criteria in OpenReport in the form of a string. So try:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "rptWorkout_Header", acViewPreview, , "[Workout_Date] = #" & Forms.frmUsers.Workout_List.Form.Workout_Date & "# And [UserName] = '" & Forms.frmUsers.Workout_List.Form.UserName & "'"

I'm assuming that your dates are actually formatted as dates, and so enclosed the date criteria in #'s.

Pat
Jul 25 '10 #2
NeoPa
32,556 Expert Mod 16PB
The parameter does indeed, need to be a string, but the values needn't be. Date values, if they are to be formatted as literals within the strings should be properly formatted as SQL dates ("\#m/d/yyyy\# - See Literal DateTimes and Their Delimiters (#)).
Expand|Select|Wrap|Line Numbers
  1. Private Sub Workout_Date_Click()
  2.     DoCmd.OpenReport "rptWorkout_Header", _
  3.                      acViewPreview, , _
  4.                      "([Workout_Date] = Forms.frmUsers.Workout_List.Form.Workout_Date) " & _
  5.                      "And ([UserName] = Forms.frmUsers.Workout_List.Form.UserName)"
  6. End Sub
Jul 29 '10 #3

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

Similar topics

7
by: wwwords | last post by:
I have a form in Access 2007 containing a subform. The control source of the latter is SELECT DISTINCTROW ., ., ., ., . FROM ; which is undoubtedly correct. However, if I click on the down...
17
by: Neil | last post by:
A client of mine likes some of the new bells and whistles in Access 2007, and is thinking about converting our A03 format MDB to an A07 format file. However, while some of the users have A07, many...
4
by: lupo666 | last post by:
Hi everybody, this time I have three problems driving me nuts :-((( (1) I have a report with 20 or so Yes/No "squares". Is there a way to either hide/show the "square" or change the yes/no...
8
by: elias.farah | last post by:
Hello Everyone, I'm having some very weird behavior on a couple of Access forms. (Not all forms, just some of them). The forms have been working for years, under Access XP/2003 etc, and last...
3
by: cwoll | last post by:
Hi I need help. I have a ms access 2003 database that I would like to upgrade to ms access 2007. The first time I opened I had to fix a few references it wanted a DAO2535.TLB file witch I gave it,...
5
by: CindySue | last post by:
I'm using a subform linked to the main form by a bidder number field. In the subform, I added a group header and put the field LS in it so that it would list all records designated as Live first...
4
by: hausj0dw | last post by:
How can I rermove the sort option on columns displayed on a form. This database is access 2003, some users have access 2007. The 2007 users want the sort option removed.
1
by: tbeer | last post by:
Hello. I have created a 2007 database to help organize a golf outing event which requires the collection and tracking of a lot of linked data. Everything in my dbase is linked to my Main Business...
1
by: JasonWinchester | last post by:
Hi All, I am a GIS analyst with zero experience working with Access. Everything I do know has been 'self taught' by browsing websites like this one. So we're off to a good start, right? My...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.