Retrieving the current record number from within a sub-form

C

Costa Zu

How do I retrieve the record number in a form using a button in a sub
form?

I'm trying to:


Private Sub SelectModel(SelectedModel)
Dim CurrentModel As Long
Dim text As String
' do something with the current model
CurrentModel = frmMaster.CurrentRecord
text = Str(CurrentModel)
MsgBox (text)
' then goto the model requested
DoCmd.GoToRecord acDataForm, "Master", acGoTo, SelectedModel
End Sub

but I get the message: "Object variable or With block variable not
set".

I have the following code in the general declarations section:

Option Compare Database
Dim frmMaster As Form_Master
Dim SelectedModel As Long


Help greatly appreciated,

Regards

Costa
 
J

John Nurick

CurrentModel = Me.Parent.CurrentRecord

How do I retrieve the record number in a form using a button in a sub
form?

I'm trying to:


Private Sub SelectModel(SelectedModel)
Dim CurrentModel As Long
Dim text As String
' do something with the current model
CurrentModel = frmMaster.CurrentRecord
text = Str(CurrentModel)
MsgBox (text)
' then goto the model requested
DoCmd.GoToRecord acDataForm, "Master", acGoTo, SelectedModel
End Sub

but I get the message: "Object variable or With block variable not
set".

I have the following code in the general declarations section:

Option Compare Database
Dim frmMaster As Form_Master
Dim SelectedModel As Long


Help greatly appreciated,

Regards

Costa
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top