HELP with Subform Coding

N

NEWER USER

I have two unbound fields on a form that I use for Search boxes and two
subforms forms linked to its corresponding Search box. "Search" and "SearchJ"
and linked with Child Field (Number ID) and Master Field (Search) and Child
Field (JNumberID) and Master Field (SearchJ). On the After Update Event of
both Search boxes, the cursor moves to the respective subform anfd retrieves
the correct record. I would like to ELIMINATE one of the subforms and USING
CODE change the Child Fields and Master Fields based on which Search Box I am
using. I tried using IF statements in the Child/Master Fields and keep
getting syntax errors. I am not sure whether If statements are even allowed
or perhaps my wording is incorrect. Both Dearch Boxes and subforms are
overlapping each other on the Main Form and made visible using a checkbox for
the Search box used. So..
One one of the subform's properties

In the Child Fields row, I wrote

=If(frmOrder.Chkbox = -1, "NumberID","JNumberID")

In the Master Fields row, I wrote
=If(frmOrde.Chkbox = -1 "Search","SearchJ")

Syntax Errors - tried omitting the quotes and same error.

Can anyone suggest an alternative method or CODING that may resolve my
dilemna?
 
J

Jeanette Cunningham

Hi,
I just did the same sort of thing yesterday.
Remove all code from the child fields and master fields in the property
sheet for the subforms.
The following code goes behind the form.
Here is the code I used, just make the changes you need to fit your forms
and search boxes.
Subform1 is the name of the subform control, it is not the name of the form
that sits on the subform control.


If Split(Me.OpenArgs, "|")(6) = "visit" Then

With Me.subform1

.LinkChildFields = "[VisSiteNo]"

.LinkMasterFields = "[VisSiteNo]"

End With

Else

With Me.subform1

.LinkChildFields = "[TrID]"

.LinkMasterFields = "[TrID]"

End With

End If

End If



Jeanette Cunningham
 
N

NEWER USER

Jeanette Cunningham said:
Hi,
I just did the same sort of thing yesterday.
Remove all code from the child fields and master fields in the property
sheet for the subforms.
The following code goes behind the form.
Here is the code I used, just make the changes you need to fit your forms
and search boxes.
Subform1 is the name of the subform control, it is not the name of the form
that sits on the subform control.


If Split(Me.OpenArgs, "|")(6) = "visit" Then

With Me.subform1

.LinkChildFields = "[VisSiteNo]"

.LinkMasterFields = "[VisSiteNo]"

End With

Else

With Me.subform1

.LinkChildFields = "[TrID]"

.LinkMasterFields = "[TrID]"

End With

End If

End If



Jeanette Cunningham





NEWER USER said:
I have two unbound fields on a form that I use for Search boxes and two
subforms forms linked to its corresponding Search box. "Search" and
"SearchJ"
and linked with Child Field (Number ID) and Master Field (Search) and
Child
Field (JNumberID) and Master Field (SearchJ). On the After Update Event
of
both Search boxes, the cursor moves to the respective subform anfd
retrieves
the correct record. I would like to ELIMINATE one of the subforms and
USING
CODE change the Child Fields and Master Fields based on which Search Box I
am
using. I tried using IF statements in the Child/Master Fields and keep
getting syntax errors. I am not sure whether If statements are even
allowed
or perhaps my wording is incorrect. Both Dearch Boxes and subforms are
overlapping each other on the Main Form and made visible using a checkbox
for
the Search box used. So..
One one of the subform's properties

In the Child Fields row, I wrote

=If(frmOrder.Chkbox = -1, "NumberID","JNumberID")

In the Master Fields row, I wrote
=If(frmOrde.Chkbox = -1 "Search","SearchJ")

Syntax Errors - tried omitting the quotes and same error.

Can anyone suggest an alternative method or CODING that may resolve my
dilemna?
 
N

NEWER USER

Thanks for your assistance. I took your ideas and made them work for me.
Thanks again and Happy Holidays.

Jeanette Cunningham said:
Hi,
I just did the same sort of thing yesterday.
Remove all code from the child fields and master fields in the property
sheet for the subforms.
The following code goes behind the form.
Here is the code I used, just make the changes you need to fit your forms
and search boxes.
Subform1 is the name of the subform control, it is not the name of the form
that sits on the subform control.


If Split(Me.OpenArgs, "|")(6) = "visit" Then

With Me.subform1

.LinkChildFields = "[VisSiteNo]"

.LinkMasterFields = "[VisSiteNo]"

End With

Else

With Me.subform1

.LinkChildFields = "[TrID]"

.LinkMasterFields = "[TrID]"

End With

End If

End If



Jeanette Cunningham





NEWER USER said:
I have two unbound fields on a form that I use for Search boxes and two
subforms forms linked to its corresponding Search box. "Search" and
"SearchJ"
and linked with Child Field (Number ID) and Master Field (Search) and
Child
Field (JNumberID) and Master Field (SearchJ). On the After Update Event
of
both Search boxes, the cursor moves to the respective subform anfd
retrieves
the correct record. I would like to ELIMINATE one of the subforms and
USING
CODE change the Child Fields and Master Fields based on which Search Box I
am
using. I tried using IF statements in the Child/Master Fields and keep
getting syntax errors. I am not sure whether If statements are even
allowed
or perhaps my wording is incorrect. Both Dearch Boxes and subforms are
overlapping each other on the Main Form and made visible using a checkbox
for
the Search box used. So..
One one of the subform's properties

In the Child Fields row, I wrote

=If(frmOrder.Chkbox = -1, "NumberID","JNumberID")

In the Master Fields row, I wrote
=If(frmOrde.Chkbox = -1 "Search","SearchJ")

Syntax Errors - tried omitting the quotes and same error.

Can anyone suggest an alternative method or CODING that may resolve my
dilemna?
 

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