Dear Access Master,
I have a problem about updating table from a form.
I have a table named TableData and want to update the value in TableData from my form named formA with subform named subformB. In my subformB there textbox named Record No and No. I place the cursor on subformB and click the button, it works until msgbox, but doesn't work on the next code. Do you have any idea what's missing in my VBA code ? Thanks,
Here's my VBA code :
Private Sub Command104_Click()
Dim iStartNo As Long
Dim IStartRecordNo As Long
Dim IPrevRecordNo As Long
iStartNo = [Forms]![FormA]![SubformB].[Form]![No]
IStartRecordNo = [Forms]![FormA]![SubformB].[Form]![RecordNo]
IPrevRecordNo = IStartRecordNo - 1
MsgBox ("" & iStartNo & "")
MsgBox ("" & IStartRecordNo & "")
MsgBox ("" & IPrevRecordNo & "")
DoCmd.SetWarnings False
strSql = "UPDATE TableData SET TableData.RecordNo = '" & IPrevRecordNo & "' WHERE (((TableData.[No])='" & iStartNo & "'));"
DoCmd.RunSQL strSql
DoCmd.SetWarnings True
[Forms]![FormA]![SubformB].[Form].Requery
End Sub