Re: Update table from form combo



It's not clear whether you want to add a new record because you try to set
the EmployeeID in your example. However, from the rest of your description,
it sounds like you just want to update an existing record. Anyway, I'm not
sure if your post got cut-off or whether your code is incorrect, but try this
to update the table:

SQLstrg = "UPDATE Clock_Table SET [StopDate] = #" & Me.StopDate & "# WHERE ((
[StopDate] Is Null) AND ([EmployeeID] = " & Me.[EmployeeId].[Column(1)] & "))
;"


Gaetanm wrote:
I’m new at this and trying very hard. Can anyone help?
My table that needs to be updated is Clock_Table
The table has four (4) fields JobId, EmployeeID, StartDate, StopDate

My form called StopTime has a combo box bound to this table.
The combo does a query EmployeeID that StartDate is not Null and StopDate
Is Null. The combo box display the EmployeeId. I have a field on the Form
that is populated via a button that has the Now statement. That part works.

I’m trying to update the existing row to the table with the Employee value in
the combo box as point of reference and update StopDate in the table with the
StopDate data
that was put on the form via the Now statement.

I tried with the following code via a command button but its not working It
comes up with a dialogue box asking to put the variable in then another
dialogue box pops telling me 0 records will be updated .

Private Sub Command21_Click()

Dim SQLstrg As String
SQLstrg = "Update Clock_Table Set EmployeeId = [EmployeeId].[Column(1)],
StopDate = [StopDate] Where StopDate = Null"
DoCmd.RunSQL SQLstrg
End Sub

Can anyone please help

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200610/1

.


Loading