beginner83
Registered User.
- Local time
- Today, 03:49
- Joined
- Jun 13, 2013
- Messages
- 11
Hi All,
I've been playing around with creating my own class in VBA but I'm having problems calling its methods. My class is pretty basic, its called cDentist and the properties are just Name, Address, DOB etc and one method AddDentist. AddDentist will add the details to a sql server table.
So I create an instance of the class in a module called Dentist. At the very top of the code i put..
I have a method then in module Dentist, where I initialise the instance of class cDentist and i populate it's properities...
My problem comes then in a form where the user enters the dentist details and clicks 'Save' button. Code below is on 'Save' button..
When I click 'Save' I get error, Method or data member not found. And '.AddDentist' is highlighted. I'm a little confused why it's not seeing AddDentist as a method of class cDentist.
Any advice is greatly appreciated
I've been playing around with creating my own class in VBA but I'm having problems calling its methods. My class is pretty basic, its called cDentist and the properties are just Name, Address, DOB etc and one method AddDentist. AddDentist will add the details to a sql server table.
So I create an instance of the class in a module called Dentist. At the very top of the code i put..
Code:
Option Compare Database
Global Dentist As cDentist
I have a method then in module Dentist, where I initialise the instance of class cDentist and i populate it's properities...
Code:
Sub RecordDentistDetails()
Set Dentist = New cDentist
Dentist.Name = Forms!frm_enterdetails!txtName
Dentist.Address = Forms!frm_enterdetails!txtAddress
Dentist.dob = Forms!frm_enterdetails!txtdob
End Sub
My problem comes then in a form where the user enters the dentist details and clicks 'Save' button. Code below is on 'Save' button..
Code:
RecordDentistDetails
Dentist.AddDentist
When I click 'Save' I get error, Method or data member not found. And '.AddDentist' is highlighted. I'm a little confused why it's not seeing AddDentist as a method of class cDentist.
Any advice is greatly appreciated
