craigachan
Registered User.
- Local time
- Today, 06:33
- Joined
- Nov 9, 2007
- Messages
- 285
I have a front end Access 365 and backend sql server database. I get a runtime 3155 when trying to insert a record into the sql table. I haven't found any suitable solution yet. It errors out at rsR.Update. Any help is appreciated.
Code:
Private Sub cmdAddSelect_Click()
On Error GoTo cmdAddSelectErr
Dim db As DAO.Database, rsR As DAO.Recordset, strRID As String, strRName As String, strCity, stroForm As String, msql As String
'======Validate info
If IsNull(Me.RLast) Then
MsgBox "Enter Contributor Lastname"
Exit Sub
End If
If IsNull(Me.RFirst) Then
MsgBox "Enter Contributor Firstname"
Exit Sub
End If
If IsNull(Me.RAddr) Then
MsgBox "Enter Contributor Street"
Exit Sub
End If
If IsNull(Me.RCity) Then
MsgBox "Enter Contributor City"
Exit Sub
End If
If IsNull(Me.RState) Then
MsgBox "Enter Contributor State"
Exit Sub
End If
If IsNull(Me.RZip) Then
MsgBox "Enter Contributor Zip Code"
Exit Sub
End If
If IsNull(Me.RTel) Then
MsgBox "Enter Contributor Telephone"
Exit Sub
End If
If IsNull(Me.Degree) Then
MsgBox "Enter Contributor Degree(s)"
Exit Sub
End If
If IsNull(Me.REmail) Then
MsgBox "Enter Contributor Email"
Exit Sub
End If
If IsNull(Me.cboSpecialty) Then
MsgBox "Enter Contributor Specialty"
Exit Sub
End If
'=======Add to referral table
DoEvents
DoEvents
strRName = Me.RLast & ", " & Me.RFirst
strCity = Me.RCity
Set db = OpenDatabase("", False, False, CurrentDb.TableDefs("referral").Connect)
Set rsR = Db.OpenRecordset("Referral")
With rsR
.AddNew
!typ = "9"
!Last = Me.RLast
!First = Me.RFirst
strRName = Me.RLast & ", " & Me.RFirst
!Degree = Me.Degree
!email = Me.REmail
!Street = Me.RAddr
!City = Me.RCity
strCity = Me.RCity
!State = Me.RState
!Zip = Me.RZip
!Work = Me.RTel
!Npi = Me.RNPI
.Update
.MoveLast
strRID = !ID 'Get RID just made
End With
rsR.Close
'=======Return referral info to oForm
stroForm = Me.oForm
Select Case oForm
Case "PatientAdd"
Forms(stroForm).RName = strRName
Forms(stroForm).RefCity = strrcity
Forms(stroForm).Referral = strRID
End Select
cmdAddSelectExit:
Set rsR = Nothing
Exit Sub
cmdAddSelectErr:
MsgBox "Forms!ContributorAddMain-cmdAddSelectClick: " & Err.Number & " - " & Err.Description
Resume cmdAddSelectExit
End sub
<
Last edited by a moderator: