Text update from form

  • Thread starter Gaetanm via AccessMonster.com
  • Start date
G

Gaetanm via AccessMonster.com

I have a bound (NOTE) text box on my form txtJob_activity, to my clock_table
in the Activity column. I'm able to update everything else on the form but
can't seem to get this text in the box to update the record.
Here is my code to update via a button:

Private Sub Command21_Click()
DoCmd.SetWarnings False
Dim SQLstrg As String

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

DoCmd.RunSQL SQLstrg
DoCmd.SetWarnings True
Me.cboEmployeeID = Null
Me.StopDate = Null
Me.txtJob_Activity = Null
DoCmd.OpenForm "frmclock_start_table"
DoCmd.SelectObject acForm, "frmclock_start_table"
End Sub

Any suggestions

Gaetanm
 
D

Douglas J. Steele

You need a space between the # and the keyword WHERE.

Also, just in case this code is ever run by a user whose Short Date format
is set to other than mm/dd/yyyy, you'd be safer using:

SQLstrg = "UPDATE Clock_Table SET [StopDate] = " & _
Format(Me.StopDate, "\#mm\/dd\/yyyy\#") & _
" WHERE [StopDate] Is Null " & _
" AND [EmployeeID] = " & Me.[EmployeeID]
 
G

Gaetanm via AccessMonster.com

Douglas said:
You need a space between the # and the keyword WHERE.

Also, just in case this code is ever run by a user whose Short Date format
is set to other than mm/dd/yyyy, you'd be safer using:

SQLstrg = "UPDATE Clock_Table SET [StopDate] = " & _
Format(Me.StopDate, "\#mm\/dd\/yyyy\#") & _
" WHERE [StopDate] Is Null " & _
" AND [EmployeeID] = " & Me.[EmployeeID]
I have a bound (NOTE) text box on my form txtJob_activity, to my
clock_table

Douglas
Thanks for the imput but it does not solve the problem I mention about the
text box. I don't have the text box in my code that is what I'm having a
probelm with . Any suggestions

Gaetanm
[quoted text clipped - 22 lines]
 
D

Douglas J. Steele

Gaetanm via AccessMonster.com said:
Douglas said:
You need a space between the # and the keyword WHERE.

Also, just in case this code is ever run by a user whose Short Date format
is set to other than mm/dd/yyyy, you'd be safer using:

SQLstrg = "UPDATE Clock_Table SET [StopDate] = " & _
Format(Me.StopDate, "\#mm\/dd\/yyyy\#") & _
" WHERE [StopDate] Is Null " & _
" AND [EmployeeID] = " & Me.[EmployeeID]
I have a bound (NOTE) text box on my form txtJob_activity, to my
clock_table

Douglas
Thanks for the imput but it does not solve the problem I mention about the
text box. I don't have the text box in my code that is what I'm having a
probelm with . Any suggestions

Gaetanm

Your code assumes you've put a date in the text box named StopDate, and it
updates the table using that date. Once it's updated the table, it resets
the text box to Null.

What date do you want in that text box?
 
G

Gaetanm via AccessMonster.com

Douglas said:
[quoted text clipped - 15 lines]

Your code assumes you've put a date in the text box named StopDate, and it
updates the table using that date. Once it's updated the table, it resets
the text box to Null.

What date do you want in that text box?

Hi Douglas

I do't want a date in the text box. I will be putting in information in the
text box . What I need to know is this part. How do I update the information
from my textbox to my tabel column called Activity.

In other words what do I have to add and where do I add in my update
statement that is already there
to make this happen.

All the update works fine except I cannot figure out
how to update the text to the Activity column
in my table.

Gaetanm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top