View Single Post
Old 06-03-2016, 05:29 AM   #1
helmerr
Newly Registered User
 
Join Date: Nov 2013
Posts: 140
Thanks: 33
Thanked 0 Times in 0 Posts
helmerr is on a distinguished road
method or data member not found on click

Hi everyone,

I have a form and some code that I copied from another form (because I wanted to keep the same layout) and altered one of the private subs for a button's click event. When I click the button on the newly copied and edited form, I get the error as follows:

Method or data member not found. It then highlights the top line "Private Sub btnAdd_Click." Can I get some assistance please?

Code:
Private Sub btnAdd_Click()
'
Dim db As Database
Dim rec As Recordset

Set db = CurrentDb
Set rec = db.OpenRecordset("Select * from tblOdometer")

'test required fields
If IsNull(Me.txtrmbDate) _
        Or IsNull(Me.txtrmbTimeIn) _
        Or IsNull(Me.cbormbTSASup1.Value) _
        Or IsNull(Me.cbormbLEO0400_0600.Value) Then
    
    MsgBox "Please fill in all required fields."
Else

'add records to able
rec.AddNew
rec("rmbDate") = Me.txtrmbDate
rec("rmbTimeIn") = Me.txtrmbTimeIn
rec("rmbTSASup1") = Me.rmbTSASup1
rec("rmbLEO0400-0600") = Me.rmbLEO0400_0600
rec("rmbLEO0600-1800") = Me.rmbLEO0600_1800
rec("rmbLEO1800-0100") = Me.rmbLEO1800_0100
rec("rmbTimeOut") = Me.rmbTimeOut
rec("rmbTSASup2") = Me.rmbTSASup2
'rec("rmbTotalTSAHrs") = Me.rmbTotalTSAHrs


rec.Update

Set rec = Nothing
Set db = Nothing

MsgBox "Record saved."

'Requery form
Me.Requery

' Clear All Controls
    Me.txtrmbDate = Null
    Me.txtrmbTimeIn = Null
    Me.cbormbTSASup1.Value = Null
    Me.cbormbLEO0400_0600.Value = Null
    Me.cbormbLE0600_1800.Value = Null
    Me.cbormbLEO1800_0100.Value = Null
    Me.rmbTimeOut = Null
    Me.cbormbTSASup2.Value = Null
    Me.rmbTotalTSAHrs = Null
End If
'
End Sub
Please let me know if you need more info. Thanks

helmerr is offline   Reply With Quote