473,395 Members | 1,666 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.

Copy Command using Cascading Combo Boxes in a Subform

I am building a database to track attendance. I have one main form with multiple subforms. Within one of the subforms name sfrDailyAttendance, I also have cascading combo boxes (cboCategory and cboException) to filter difference absences (ie.Regular, Overtime, etc). cboCategory is filtered as follows:

[Forms]![frmMain]![sfrDailyAttendance].[Form].[Category].

Because I have the subform set up as a continuous form, I needed to add a text box (txtException) on top of one of the combo boxes (cboException), so that when a new Category was selected, it did not reset previous Exceptions selected. tblDailyAttendance does not have a field called txtException, which I thought was the reason, however, when I added it in the table, I still received errors.

The copy button is used to increment the date if it a consecutive absence for the same reason, and have been given advice to add the following code:

strSQL = "INSERT INTO tblDailyAttendance (StartTime, EndTime, Category, Exception, " & _
"Reason, ExceptionHrs) "
strSQL = strSQL & "VALUES(#" & Me.Date + 1
strSQL = strSQL & "#,#" & Me.StartTime & "#,#" & Me.EndTime & "#," & Me.Category & _
"," & Me.Exception & "," & Me.Reason & "," & Me.ExceptionHrs & ", " & Me.Description & ");"
CurrentDb.Execute strSQL

DoCmd.RunCommand acCmdRecordsGoToLast

Everything seems to be populating correctly when I step through the code, however, I get "Syntax error (missing operator) in query expression 'Paid OT'" Paid OT is a value populated in the cboException, which also appears in txtException. I'm thinking that I need to add a WHERE clause, but not sure

Any additional assistance would be great. Thanks
Aug 17 '07 #1
2 2256
JConsulting
603 Expert 512MB
I am building a database to track attendance. I have one main form with multiple subforms. Within one of the subforms name sfrDailyAttendance, I also have cascading combo boxes (cboCategory and cboException) to filter difference absences (ie.Regular, Overtime, etc). cboCategory is filtered as follows:

[Forms]![frmMain]![sfrDailyAttendance].[Form].[Category].

Because I have the subform set up as a continuous form, I needed to add a text box (txtException) on top of one of the combo boxes (cboException), so that when a new Category was selected, it did not reset previous Exceptions selected. tblDailyAttendance does not have a field called txtException, which I thought was the reason, however, when I added it in the table, I still received errors.

The copy button is used to increment the date if it a consecutive absence for the same reason, and have been given advice to add the following code:

strSQL = "INSERT INTO tblDailyAttendance (StartTime, EndTime, Category, Exception, " & _
"Reason, ExceptionHrs) "
strSQL = strSQL & "VALUES(#" & Me.Date + 1
strSQL = strSQL & "#,#" & Me.StartTime & "#,#" & Me.EndTime & "#," & Me.Category & _
"," & Me.Exception & "," & Me.Reason & "," & Me.ExceptionHrs & ", " & Me.Description & ");"
CurrentDb.Execute strSQL

DoCmd.RunCommand acCmdRecordsGoToLast

Everything seems to be populating correctly when I step through the code, however, I get "Syntax error (missing operator) in query expression 'Paid OT'" Paid OT is a value populated in the cboException, which also appears in txtException. I'm thinking that I need to add a WHERE clause, but not sure

Any additional assistance would be great. Thanks
This sounds pretty simple. When you insert a text value using the code above, the proper format is

'" & me.somevalue & "'

let me break it out so you can see it better

' " & me.somevalue & " '

where the tick marks go outside the quotes.

J
Aug 18 '07 #2
JConsulting
603 Expert 512MB
I am building a database to track attendance. I have one main form with multiple subforms. Within one of the subforms name sfrDailyAttendance, I also have cascading combo boxes (cboCategory and cboException) to filter difference absences (ie.Regular, Overtime, etc). cboCategory is filtered as follows:

[Forms]![frmMain]![sfrDailyAttendance].[Form].[Category].

Because I have the subform set up as a continuous form, I needed to add a text box (txtException) on top of one of the combo boxes (cboException), so that when a new Category was selected, it did not reset previous Exceptions selected. tblDailyAttendance does not have a field called txtException, which I thought was the reason, however, when I added it in the table, I still received errors.

The copy button is used to increment the date if it a consecutive absence for the same reason, and have been given advice to add the following code:

strSQL = "INSERT INTO tblDailyAttendance (StartTime, EndTime, Category, Exception, " & _
"Reason, ExceptionHrs) "
strSQL = strSQL & "VALUES(#" & Me.Date + 1
strSQL = strSQL & "#,#" & Me.StartTime & "#,#" & Me.EndTime & "#," & Me.Category & _
"," & Me.Exception & "," & Me.Reason & "," & Me.ExceptionHrs & ", " & Me.Description & ");"
CurrentDb.Execute strSQL

DoCmd.RunCommand acCmdRecordsGoToLast

Everything seems to be populating correctly when I step through the code, however, I get "Syntax error (missing operator) in query expression 'Paid OT'" Paid OT is a value populated in the cboException, which also appears in txtException. I'm thinking that I need to add a WHERE clause, but not sure

Any additional assistance would be great. Thanks


as far as the where part...you want to insert the record into a specific person's records..you'll probably want to use

Where ID = " & me.ID & "

where the ID number corresponds to the ID field you use in the table.

J
Aug 18 '07 #3

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

Similar topics

2
by: Cameron | last post by:
Hi, For the database I am currently working on, my employer would like the ability to use multiple combo boxes in order to filter the database. For instance the structure of the company is based...
14
by: Kevin | last post by:
A couple of easy questions here hopefully. I've been working on two different database projects which make use of multiple forms. 1. Where's the best/recommended placement for command buttons...
3
by: Mike Jakes | last post by:
I hope that someone can offer a little advice on this one - I've searched the group but can't find an answer. I think that I'm doing something really stupid or missing something trivial, but see...
9
by: natwong | last post by:
Hi All, I'm a newbie in terms of Access and some of its functionality . I've been stuck on this problem for a couple days, even after searching the Web, etc. Currently I have five combo boxes...
4
klarae99
by: klarae99 | last post by:
Hello, I am working on an Access 2003 Database. The tables that pertain to this issue are tblOrg, tblState, tblCity, and tblZip. I have posted the table structure with only the pertinant fields...
3
kcdoell
by: kcdoell | last post by:
I have 5 cascading combo boxes on a form. Below is a sample of my vb in the first combo box: Private Sub CboDivision_AfterUpdate() 'When the Division is selected, the appropriate Segment...
5
by: samdev | last post by:
I have created two combo boxes in a subform.... For example 1. Combo Box State 2. Combo Box City 3. When a state from the Combo Box State is selected, the City combo box updates to reflect...
1
by: bluclouds9 | last post by:
I am new to Access and have been charged with creating a database for our course alumni. I currently have a "Contacts" form and am trying to create a subform to hold the course alumni...
20
by: luciegiles | last post by:
Hi, I have used the tutorial Cascading Combo/List Boxes to filter the combo box cboCareManager dependent on the entry to cboLocalityTeam - the common code between the two tables is LocalityCode. ...
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
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?
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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.