C
ChuckW
Hi,
I am a VBA novice who is attempting to move VBA code from one database to
another. The code creates some duplicate records and runs successfully when
I click a command button. I named my command button the same and changed my
code to reflect the different form names. When I click on the command button
in the new database I get an error that says "Object Doesn't support this
property or method". I went into references in the VBA code and there are
five things checked. They match exactly the five checked from the original
database where the button works. Any idea why I am getting this error
message?
I have copied my enhanced VBA code below.
Private Sub NewRecordDuplicateInfo_Click()
On Error GoTo Err_AddRecord_Click
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb()
vbCProtocolID = Forms!Protocol!ProtocolID.Value
DoCmd.GoToRecord , , acNewRec
Forms!Protocol!CustomerName.SetFocus
Forms!Protocol!CustomerName = ""
vbNProtocolID = Forms!Protocol!ProtocolID.Value
OrigProtocolID = vbCProtocolID
strSQL = "INSERT INTO ProtocolProducts (ProtocolID,ItemName, Amount)
SELECT ( " & vbNProtocolID & "), ItemName, Amount FROM ProtocolProducts WHERE
(ProtocolID = (" & OrigProtocolID & "))"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Forms!Protocol.Refresh
Exit_AddRecord_Click:
Exit Sub
Err_AddRecord_Click:
MsgBox Err.Description
Resume Exit_AddRecord_Click
End Sub
I am a VBA novice who is attempting to move VBA code from one database to
another. The code creates some duplicate records and runs successfully when
I click a command button. I named my command button the same and changed my
code to reflect the different form names. When I click on the command button
in the new database I get an error that says "Object Doesn't support this
property or method". I went into references in the VBA code and there are
five things checked. They match exactly the five checked from the original
database where the button works. Any idea why I am getting this error
message?
I have copied my enhanced VBA code below.
Private Sub NewRecordDuplicateInfo_Click()
On Error GoTo Err_AddRecord_Click
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb()
vbCProtocolID = Forms!Protocol!ProtocolID.Value
DoCmd.GoToRecord , , acNewRec
Forms!Protocol!CustomerName.SetFocus
Forms!Protocol!CustomerName = ""
vbNProtocolID = Forms!Protocol!ProtocolID.Value
OrigProtocolID = vbCProtocolID
strSQL = "INSERT INTO ProtocolProducts (ProtocolID,ItemName, Amount)
SELECT ( " & vbNProtocolID & "), ItemName, Amount FROM ProtocolProducts WHERE
(ProtocolID = (" & OrigProtocolID & "))"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Forms!Protocol.Refresh
Exit_AddRecord_Click:
Exit Sub
Err_AddRecord_Click:
MsgBox Err.Description
Resume Exit_AddRecord_Click
End Sub