Take a record value from a subform and use gotorecord in the Mainf

  • Thread starter Thread starter Chilidog
  • Start date Start date
C

Chilidog

I'm trying to pass a value from my subform and have the mainform display that
record. I have tried:

Me.Parent![mymainform].SetFocus
DoCmd.GoToRecord acDataForm, "mymainform", acGoTo, recordID_frm_Subform

That ends with a invalid use of Me keyword.

I have also passed the record number to an textbox on the mainform and then
tried
DoCmd.GoToRecord acDataForm, "mymainform", acGoTo, recordID_now_on_Mainform

And get "Cannot go to that specifed record.

Any help would be very appreciated.
 
Hi Chilidog (what is your name?)

are you trying to echo a value from the current record in the subform
or, for instance, from a calculated control in the subform footer

if one of the above, you can
1. make a textbox on the main form
2. set the controlsource to -->
=[subform_controlname].form.[controlname]

WHERE
subform_controlname is the Name property of the subform control
controlname is the Name property of the control containing the value you
wish to display

Warm Regards,
Crystal

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
(: have an awesome day :)
*
 
Crystal,

Thanks for taking a look. I have a field called ID that is populated on my
subform, I want to be able to pass that "ID" value to my mainform and have it
become the current record on the mainform. I guess the problem is how I sync
the ID (autonumber) field to what Access sees as the rowsource. E.g I pass
the ID value of 100 and get some random record on my Mainform. As such:


DoCmd.GoToRecord acDataForm, "mymainform", acGoTo, ID

Thus my ID value <> what Access sees as the record source... I really hope
that makes sense.

Thanks again!

Scott


strive4peace said:
Hi Chilidog (what is your name?)

are you trying to echo a value from the current record in the subform
or, for instance, from a calculated control in the subform footer

if one of the above, you can
1. make a textbox on the main form
2. set the controlsource to -->
=[subform_controlname].form.[controlname]

WHERE
subform_controlname is the Name property of the subform control
controlname is the Name property of the control containing the value you
wish to display

Warm Regards,
Crystal

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
(: have an awesome day :)
*



I'm trying to pass a value from my subform and have the mainform display that
record. I have tried:

Me.Parent![mymainform].SetFocus
DoCmd.GoToRecord acDataForm, "mymainform", acGoTo, recordID_frm_Subform

That ends with a invalid use of Me keyword.

I have also passed the record number to an textbox on the mainform and then
tried
DoCmd.GoToRecord acDataForm, "mymainform", acGoTo, recordID_now_on_Mainform

And get "Cannot go to that specifed record.

Any help would be very appreciated.
 
Hi Scott,

you're welcome

are you trying to find an existing record on the main form? If so, try
this:

'~~~~~~~~~~~~~
'save current record if it has changed
if me.dirty then me.dirty = false

if me.NewRecord then
msgbox "You are not on a current record",,"No current record"
exit sub
end if

with me.parent
'find the first value that matches
.RecordsetClone.FindFirst "ID = " & me.ID

'if a matching record was found, then move to it
If Not .RecordsetClone.NoMatch Then
.Bookmark = .RecordsetClone.Bookmark
End If
'~~~~~~~~~~~~~
WHERE
ID is the fieldname on the mainform and the subform -- btw, you really
should change ID to something specific like OrderID or SalesID or
CustID, ...

If not, then you should create the mainform record FIRST -- so make your
subform the mainform

Warm Regards,
Crystal

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
(: have an awesome day :)
*



Crystal,

Thanks for taking a look. I have a field called ID that is populated on my
subform, I want to be able to pass that "ID" value to my mainform and have it
become the current record on the mainform. I guess the problem is how I sync
the ID (autonumber) field to what Access sees as the rowsource. E.g I pass
the ID value of 100 and get some random record on my Mainform. As such:


DoCmd.GoToRecord acDataForm, "mymainform", acGoTo, ID

Thus my ID value <> what Access sees as the record source... I really hope
that makes sense.

Thanks again!

Scott


strive4peace said:
Hi Chilidog (what is your name?)

are you trying to echo a value from the current record in the subform
or, for instance, from a calculated control in the subform footer

if one of the above, you can
1. make a textbox on the main form
2. set the controlsource to -->
=[subform_controlname].form.[controlname]

WHERE
subform_controlname is the Name property of the subform control
controlname is the Name property of the control containing the value you
wish to display

Warm Regards,
Crystal

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
(: have an awesome day :)
*



I'm trying to pass a value from my subform and have the mainform display that
record. I have tried:

Me.Parent![mymainform].SetFocus
DoCmd.GoToRecord acDataForm, "mymainform", acGoTo, recordID_frm_Subform

That ends with a invalid use of Me keyword.

I have also passed the record number to an textbox on the mainform and then
tried
DoCmd.GoToRecord acDataForm, "mymainform", acGoTo, recordID_now_on_Mainform

And get "Cannot go to that specifed record.

Any help would be very appreciated.
 
That worked PERFECTLY!!! Thanks so much, I really appreciate it!

strive4peace said:
Hi Scott,

you're welcome

are you trying to find an existing record on the main form? If so, try
this:

'~~~~~~~~~~~~~
'save current record if it has changed
if me.dirty then me.dirty = false

if me.NewRecord then
msgbox "You are not on a current record",,"No current record"
exit sub
end if

with me.parent
'find the first value that matches
.RecordsetClone.FindFirst "ID = " & me.ID

'if a matching record was found, then move to it
If Not .RecordsetClone.NoMatch Then
.Bookmark = .RecordsetClone.Bookmark
End If
'~~~~~~~~~~~~~
WHERE
ID is the fieldname on the mainform and the subform -- btw, you really
should change ID to something specific like OrderID or SalesID or
CustID, ...

If not, then you should create the mainform record FIRST -- so make your
subform the mainform

Warm Regards,
Crystal

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
(: have an awesome day :)
*



Crystal,

Thanks for taking a look. I have a field called ID that is populated on my
subform, I want to be able to pass that "ID" value to my mainform and have it
become the current record on the mainform. I guess the problem is how I sync
the ID (autonumber) field to what Access sees as the rowsource. E.g I pass
the ID value of 100 and get some random record on my Mainform. As such:


DoCmd.GoToRecord acDataForm, "mymainform", acGoTo, ID

Thus my ID value <> what Access sees as the record source... I really hope
that makes sense.

Thanks again!

Scott


strive4peace said:
Hi Chilidog (what is your name?)

are you trying to echo a value from the current record in the subform
or, for instance, from a calculated control in the subform footer

if one of the above, you can
1. make a textbox on the main form
2. set the controlsource to -->
=[subform_controlname].form.[controlname]

WHERE
subform_controlname is the Name property of the subform control
controlname is the Name property of the control containing the value you
wish to display

Warm Regards,
Crystal

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
(: have an awesome day :)
*




Chilidog wrote:
I'm trying to pass a value from my subform and have the mainform display that
record. I have tried:

Me.Parent![mymainform].SetFocus
DoCmd.GoToRecord acDataForm, "mymainform", acGoTo, recordID_frm_Subform

That ends with a invalid use of Me keyword.

I have also passed the record number to an textbox on the mainform and then
tried
DoCmd.GoToRecord acDataForm, "mymainform", acGoTo, recordID_now_on_Mainform

And get "Cannot go to that specifed record.

Any help would be very appreciated.
 
you're welcome, Scott ;) happy to help

Warm Regards,
Crystal

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
(: have an awesome day :)
*



That worked PERFECTLY!!! Thanks so much, I really appreciate it!

strive4peace said:
Hi Scott,

you're welcome

are you trying to find an existing record on the main form? If so, try
this:

'~~~~~~~~~~~~~
'save current record if it has changed
if me.dirty then me.dirty = false

if me.NewRecord then
msgbox "You are not on a current record",,"No current record"
exit sub
end if

with me.parent
'find the first value that matches
.RecordsetClone.FindFirst "ID = " & me.ID

'if a matching record was found, then move to it
If Not .RecordsetClone.NoMatch Then
.Bookmark = .RecordsetClone.Bookmark
End If
'~~~~~~~~~~~~~
WHERE
ID is the fieldname on the mainform and the subform -- btw, you really
should change ID to something specific like OrderID or SalesID or
CustID, ...

If not, then you should create the mainform record FIRST -- so make your
subform the mainform

Warm Regards,
Crystal

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
(: have an awesome day :)
*



Crystal,

Thanks for taking a look. I have a field called ID that is populated on my
subform, I want to be able to pass that "ID" value to my mainform and have it
become the current record on the mainform. I guess the problem is how I sync
the ID (autonumber) field to what Access sees as the rowsource. E.g I pass
the ID value of 100 and get some random record on my Mainform. As such:


DoCmd.GoToRecord acDataForm, "mymainform", acGoTo, ID

Thus my ID value <> what Access sees as the record source... I really hope
that makes sense.

Thanks again!

Scott


:

Hi Chilidog (what is your name?)

are you trying to echo a value from the current record in the subform
or, for instance, from a calculated control in the subform footer

if one of the above, you can
1. make a textbox on the main form
2. set the controlsource to -->
=[subform_controlname].form.[controlname]

WHERE
subform_controlname is the Name property of the subform control
controlname is the Name property of the control containing the value you
wish to display

Warm Regards,
Crystal

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
(: have an awesome day :)
*




Chilidog wrote:
I'm trying to pass a value from my subform and have the mainform display that
record. I have tried:

Me.Parent![mymainform].SetFocus
DoCmd.GoToRecord acDataForm, "mymainform", acGoTo, recordID_frm_Subform

That ends with a invalid use of Me keyword.

I have also passed the record number to an textbox on the mainform and then
tried
DoCmd.GoToRecord acDataForm, "mymainform", acGoTo, recordID_now_on_Mainform

And get "Cannot go to that specifed record.

Any help would be very appreciated.
 
Back
Top