D
dmacpherson via AccessMonster.com
I don't know if this is the correct forum to ask this Q.
Win 2000, Access 2003 SQL Server 2000
I want to update the Vendor tbl with a new entry if it is not already present
in the table. I can get it to work fine if the tbl is local in Access (see
code below) but it does not update the tbl if I move it onto the SQL back end.
What VBA coding differences are there with the SQL route other than setting
key field to INT Indentity, Identity Seed and Identity increment on the SQL
tbl ??
Private Sub Vendor_NotInList(NewData As String, Response As Integer)
Response = acDataErrContinue
'Prompt user to verify if they wish to add new value
If MsgBox("Vendor " & NewData & " is not in list. Add it ?", vbYesNo) =
vbYes Then
Dim db As Database
Dim rstVendor As Recordset
Dim sqlVendors As String
Set db = CurrentDb()
sqlVendors = "Select * from dbo_Vendors"
Set rstVendor = db.OpenRecordset(sqlVendors, dbOpenDynaset)
rstVendor.AddNew
rstVendor![Vendors] = NewData
rstVendor.Update
Response = acDataErrAdded
MsgBox "The new Vendor has been added to the list"
rstVendor.Close
End If
End Sub
Win 2000, Access 2003 SQL Server 2000
I want to update the Vendor tbl with a new entry if it is not already present
in the table. I can get it to work fine if the tbl is local in Access (see
code below) but it does not update the tbl if I move it onto the SQL back end.
What VBA coding differences are there with the SQL route other than setting
key field to INT Indentity, Identity Seed and Identity increment on the SQL
tbl ??
Private Sub Vendor_NotInList(NewData As String, Response As Integer)
Response = acDataErrContinue
'Prompt user to verify if they wish to add new value
If MsgBox("Vendor " & NewData & " is not in list. Add it ?", vbYesNo) =
vbYes Then
Dim db As Database
Dim rstVendor As Recordset
Dim sqlVendors As String
Set db = CurrentDb()
sqlVendors = "Select * from dbo_Vendors"
Set rstVendor = db.OpenRecordset(sqlVendors, dbOpenDynaset)
rstVendor.AddNew
rstVendor![Vendors] = NewData
rstVendor.Update
Response = acDataErrAdded
MsgBox "The new Vendor has been added to the list"
rstVendor.Close
End If
End Sub