Tina,
As I mentioned in my post to Stefan. I don't think you are going to be able
to set the value of your [StatusFlag] field to " ". Access will not allow a
space character as the only character in a text field. You could set it to
an empty string "", but not to a space.
Your query "Serial Update" will only update the record currently displayed
on the form. You could do this just as easily by setting the value of the
field (see code below), but as I mentioned above, it will only work if you
set the value to "", not " ".
If you want to set the value of [StatusFlag] for multiple records which meet
some criteria, then, as I mentioned in my post to you on the other thread,
you will need to add another (unbound) control to your form (call it
txt_Criteria), I usually put these in the forms header. Then, you can enter
a criteria for your [LotNumber] field so that the code behind the command
button would update [StatusFlag] for multiple records.
Private Sub update_Click
Dim strSQL as string
Dim strCriteria as string
strCriteria = "[LotNumber] Like '" & me.txt_Criteria & "'"
msgbox "This will update " _
& "DCOUNT("[LotNumber]", "dbo_DataLots", strCriteria) & " " _
& "records."
strSQL = "UPDATE dbo_DataLots " _
& "SET [StatusFlag] = '' " _
& "WHERE [LotNumber] Like '" & me.txt_Criteria & "'"
Currentdb.execute strsql, dbfailonerror
End Sub
--
HTH
Dale
email address is invalid
Please reply to newsgroup only.
tina said:
Hi
all my fields are text / strings and am trying to get form to update table
as when get it to run query only updating first record.
query sql is
UPDATE dbo_DataLots SET dbo_DataLots.StatusFlag = " "
WHERE (((dbo_DataLots.LotNumber)=[forms]![serial]![LotNumber]));
command in form is
Private Sub update_Click()
On Error GoTo Err_update_Click
Dim stDocName As String
stDocName = "SERIAL UPDATE"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Exit_update_Click:
Exit Sub
Err_update_Click:
MsgBox Err.Description
Resume Exit_update_Click
End Sub
AS this was only updating selected record i tried to run using
strSQL = "UPDATE dbo_DataLots " & _
"SET StatusFlag = ' ' & " _
"WHERE [LotNumber] = '" & Replace(Me.LotNumber, "'", "''") & "'"
as suggested this only updates selected record aswell how can I updat eall
records shown in form
Thanks
Tina
She posted another message yesterday, in which I gave her the syntax to
update a field based on a Like statement in here WHERE clause. But it didn't
occur to me until this morning that Access will not allow you to store a
space in a text field. It will allow leading spaces, followed by text, but
it will not allow a single space, or trailing spaces (it is as if it uses
RTRIM to trim all trailing spaces before it saves a text field).
--
HTH
Dale
email address is invalid
Please reply to newsgroup only.