Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rate Thread Display Modes
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
Old 06-03-2016, 05:43 AM   #2
Minty
AWF VIP
 
Minty's Avatar
 
Join Date: Jul 2013
Location: UK - Wiltshire
Posts: 6,435
Thanks: 165
Thanked 1,738 Times in 1,707 Posts
Minty is a jewel in the rough Minty is a jewel in the rough Minty is a jewel in the rough
Re: method or data member not found on click

Copy your code minus the sub names then delete the whole thing. Go back to your form and create a new OnClick event procedure. Paste your code back in. Access keeps track of event procedures in dark and mysterious way and the Voodoo gets upset when you mess with it.
__________________
If we have helped please add to our reputation - click the scales symbol on the left, tick 'I approve' and leave a comment.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Minty is offline   Reply With Quote
The Following User Says Thank You to Minty For This Useful Post:
helmerr (06-03-2016)
Old 06-03-2016, 05:50 AM   #3
helmerr
Newly Registered User
 
Join Date: Nov 2013
Posts: 140
Thanks: 33
Thanked 0 Times in 0 Posts
helmerr is on a distinguished road
Re: method or data member not found on click

Hmm. Ok, i copied and then deleted everything. Access then prompted me to use the macro or code builder this time, and I pasted the content (minus the subs) back but I still get the same error :-(

helmerr is offline   Reply With Quote
Old 06-03-2016, 05:57 AM   #4
Galaxiom
Super Moderator
 
Join Date: Jan 2009
Location: NSW Australia
Posts: 11,657
Thanks: 98
Thanked 1,500 Times in 1,415 Posts
Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold
Re: method or data member not found on click

Could be a corrupted form.

Select all the objects on the form. Copy and paste them to a new form.

Copy and paste all the code to the new form's module. (You can create the module by adding an event to one object.) Go though and add Event Procedure to each object that has a Sub. Usually they link up again just fine.
Galaxiom is offline   Reply With Quote
The Following User Says Thank You to Galaxiom For This Useful Post:
helmerr (06-03-2016)
Old 06-03-2016, 06:05 PM   #5
helmerr
Newly Registered User
 
Join Date: Nov 2013
Posts: 140
Thanks: 33
Thanked 0 Times in 0 Posts
helmerr is on a distinguished road
Re: method or data member not found on click

Thanks everyone. Neither of those actually worked (but could have played a part in the fix). I'm really not sure what did it. I ended up creating a new blank form and pasting in from the old, and pasting in the code for each sub. When that didn't work, I commented out each line and got down to the "me.requery" and it gave a different error. At least I was past the previous. At any rate, its working properly. Thanks again

helmerr is offline   Reply With Quote
Reply

Tags
button , click , event , private sub

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
method or data member not found calgarian Forms 7 05-13-2013 10:36 AM
Question Method or data member not found Stemdriller General 3 10-02-2009 03:36 AM
Method or data member not found hugparty General 16 04-10-2009 02:15 AM
Method or data member not found zackat Modules & VBA 6 04-18-2006 04:11 AM
Method or data member not found lynsey2 General 9 08-06-2002 04:46 AM




All times are GMT -8. The time now is 03:09 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World