By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,647 Members | 1,588 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,647 IT Pros & Developers. It's quick & easy.

SQL Syntax: Can anyone help?

P: n/a
Hi All

Access 2007 Windows XP

I have a table called:
UsystblApplication

Which has 2 fields called:
1. FieldName
2. Number

I want to be able to Update the reccord from a form which
has a control called:
1. Me.txtLastUsedRecordProject

And do it from a Command Button. I am using the code below,
and although I get the warning that I won't be able to undo it.
It just doesn't not alter. Here is the code I am using
Can anyone help?

Private Sub CmdLastUsedRecord_Click()

Dim strSQL As String
strSQL = "UPDATE UsystblApplication SET [Number]= " _
& txtLastUsedRecordProject _
& " WHERE UsystblApplication.Number= &
Me.txtLastUsedRecordProject"
DoCmd.RunSQL

End Sub

Apr 24 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
You didn't give the SQL statement to the RunSQL command:

Private Sub CmdLastUsedRecord_Click()

Dim strSQL As String
strSQL = "UPDATE UsystblApplication SET [Number]= " _
& txtLastUsedRecordProject _
& " WHERE UsystblApplication.Number= &
Me.txtLastUsedRecordProject"
DoCmd.RunSQL strSQL

End Sub

By the way, our recommendation here would be to use the .Execute method of
the CurrentDb object because it will let you trap for errors:
Private Sub CmdLastUsedRecord_Click()

Dim strSQL As String
Dim dbs As DAO.Database
strSQL = "UPDATE UsystblApplication SET [Number]= " _
& txtLastUsedRecordProject _
& " WHERE UsystblApplication.Number= &
Me.txtLastUsedRecordProject"
Set dbs = CurrentDb
dbs.Execute strSQL, dbFailOnError
dbs.Close
Set dbs = Nothing

End Sub
--

Ken Snell
<MS ACCESS MVP>

"bobdydd" <re**************@yahoo.co.ukwrote in message
news:11**********************@o40g2000prh.googlegr oups.com...
Hi All

Access 2007 Windows XP

I have a table called:
UsystblApplication

Which has 2 fields called:
1. FieldName
2. Number

I want to be able to Update the reccord from a form which
has a control called:
1. Me.txtLastUsedRecordProject

And do it from a Command Button. I am using the code below,
and although I get the warning that I won't be able to undo it.
It just doesn't not alter. Here is the code I am using
Can anyone help?

Private Sub CmdLastUsedRecord_Click()

Dim strSQL As String
strSQL = "UPDATE UsystblApplication SET [Number]= " _
& txtLastUsedRecordProject _
& " WHERE UsystblApplication.Number= &
Me.txtLastUsedRecordProject"
DoCmd.RunSQL

End Sub

Apr 24 '07 #2

P: n/a
On Apr 25, 4:20 am, bobdydd <reallyuseful2...@yahoo.co.ukwrote:
Hi All

Access 2007 Windows XP

I have a table called:
UsystblApplication

Which has 2 fields called:
1. FieldName
2. Number

I want to be able to Update the reccord from a form which
has a control called:
1. Me.txtLastUsedRecordProject

And do it from a Command Button. I am using the code below,
and although I get the warning that I won't be able to undo it.
It just doesn't not alter. Here is the code I am using
Can anyone help?

Private Sub CmdLastUsedRecord_Click()

Dim strSQL As String
strSQL = "UPDATE UsystblApplication SET [Number]= " _
& txtLastUsedRecordProject _
& " WHERE UsystblApplication.Number= &
Me.txtLastUsedRecordProject"
DoCmd.RunSQL

End Sub
1. What is the value of Me!txtLastUsedRecordProject ?

2. Try this:

strSQL = "UPDATE UsystblApplication SET [Number]= " & _
txtLastUsedRecordProject & _
" WHERE UsystblApplication.Number= " & _
Me!txtLastUsedRecordProject

3. Are you updating the correct field?

Bubbles
Apr 26 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.