Full Version: Cannot get unbound form to update
UtterAccess Forums > Microsoft® Access > Access Forms
Buffaloes_77
I'm using the following code to update my table from an unbound form:
CODE

Private Sub cmdSaveClient_Click()
    Dim rs As ADODB.Recordset
    
    rs.Open "tblClients", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
    rs.AddNew
    rs!AlternateID = Me.txtAlternateID
    rs!FirstName = Me.txtFirstName
    rs!LastName = Me.txtLastName
    rs!DateOfBirth = Me.txtDateOfBirth
    rs!Gender = Me.txtGender
    rs!Race = Me.txtRace
    rs!MaritalStatus = Me.txtMaritalStatus
    rs!Language = Me.txtLanguage
    rs!HeightFeet = Me.txtHeightFeet
    rs!HeightInches = Me.txtHeightInches
    rs!Weight = Me.txtWeight
    rs!Address = Me.txtAddress
    rs!UnitNumber = Me.txtUnitNumber
    rs!City = Me.txtCity
    rs!State = Me.txtState
    rs!ZipCode = Me.txtZipCode
    rs!PrimaryPhone = Me.txtPrimaryPhone
    rs!PrimaryPhoneType = Me.txtPrimaryPhoneType
    rs!AlternatePhone = Me.txtAlternatePhone
    rs!AlternatePhoneType = Me.txtAlternatePhoneType
    rs!ProgramStatus = Me.txtProgramStatus
    rs!ClientNotes = Me.txtClientNotes
    rs.Update
    rs.Close
    Set rs = Nothing
End Sub

I keep getting an error stating that "Object variable or With block variable not set."
I've looked over it until my eyes bled. What's wrong with this?
ALaRiva
Change:
Dim rs As ADODB.Recordset
o:
Dim rs As New ADODB.Recordset
Buffaloes_77
That worked perfect.
Thanks alot!
ALaRiva
You're Welcome sad.gif
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.