Solved

Parameter Value when running code

Posted on 2008-06-18
12
213 Views
Last Modified: 2013-11-28
I am asked to enter a parameter value when I run this code. Anybody know why.

Thanks
Private Sub btn_Update_Days_Worked_Click()
 
   Dim WeekNumber As Byte
   Dim DayOfWeek As Byte
   Dim WeekText(1 To 2) As String
   Dim CurrentCheckBox As CheckBox
   
   For WeekNumber = 1 To 2
      For DayOfWeek = 1 To 7
         Set CurrentCheckBox = Me("WKDay" & LeadingZero(DayOfWeek + ((WeekNumber - 1) * 7)))
         If CurrentCheckBox = 0 Then
            WeekText(WeekNumber) = WeekText(WeekNumber) & "X"
         Else
            WeekText(WeekNumber) = WeekText(WeekNumber) & GetFirstLetterOfDay(DayOfWeek)
         End If
      Next
   Next
   DoCmd.RunSQL "INSERT INTO tbl_EmployeeShiftInformation (DaysWorkedWK1, DaysWorkedWK2) VALUES ([WeekText(1)], [WeekText(2)])"
   
End Sub

Open in new window

0
Comment
Question by:life42
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 3
  • +1
12 Comments
 
LVL 3

Expert Comment

by:BitRunner303
ID: 21812925
See if this works:

DoCmd.RunSQL "INSERT INTO tbl_EmployeeShiftInformation (DaysWorkedWK1, DaysWorkedWK2) VALUES (""" & WeekText(1) & """, """ & WeekText(2) & """)"
0
 
LVL 19

Expert Comment

by:frankytee
ID: 21812945
the error is this line:
 DoCmd.RunSQL "INSERT INTO tbl_EmployeeShiftInformation (DaysWorkedWK1, DaysWorkedWK2) VALUES ([WeekText(1)], [WeekText(2)])"

it should be:
 DoCmd.RunSQL "INSERT INTO tbl_EmployeeShiftInformation (DaysWorkedWK1, DaysWorkedWK2) VALUES ('" & WeekText(1) & "','" & WeekText(2) & "')"
0
 

Author Comment

by:life42
ID: 21813030
I now get the following message: Microsoft Office can't append all the records in the append query.

I just want to update a single record in the table.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 19

Expert Comment

by:frankytee
ID: 21813137
thats because your sql statement is an insert (ie append) and not an update statement
an update statement would be something like:
DoCmd.RunSQL "update tbl_EmployeeShiftInformation set DaysWorkedWK1 ='" & WeekText(1) & ', DaysWorkedWK2 = '" & WeekText(2) & "'" & " WHERE ..... whatever record id etc"


0
 
LVL 19

Accepted Solution

by:
frankytee earned 250 total points
ID: 21813152
typo, it should be (replace accordingly):
DoCmd.RunSQL "update tbl_EmployeeShiftInformation set DaysWorkedWK1 ='" & WeekText(1) & "', DaysWorkedWK2 = '" & WeekText(2) & "'" & " WHERE whateverIDfield = " & whateverid
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 21813162
you will need an update query not an insert (append) query

0
 

Author Comment

by:life42
ID: 21813163
frankytee, I will try this, but low group question , why an update not an insert statement.

Thank you
0
 

Author Comment

by:life42
ID: 21813443
What do I do if I am populating a new table with empty fields how do I write this UPDATE statement?
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 21813665
life42,

updating a field in a table means revising/editing the fields value of an existing record.

appending to a table means inserting/adding a new record to the table.


what do you want to do?
0
 

Author Comment

by:life42
ID: 21813704
I want to update a table, that has employee id employee name and department already populated I want to add what days of the week they work based on checkbox values. I have the checkbox values stored, I just need to update the employee record in the table based on the input from the form.

0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 21813899
frankytee already posted the codes at http:#a21813152
0
 

Author Closing Comment

by:life42
ID: 31468326
Thank you
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question