Continuous Form on Tab Control

G

Guest

I have a continuous form on a tab control form. Both forms are related to the
Client table. On click in the continuous form I have "Me.Parent.ClientID =
Me.ClientID". I want the tab control to display the Client record selected in
the continuous form. When I run it I get the message: "You can't assign a
value to this object." What to do?
 
T

tina

your description is not clear. do you mean that you have an unbound form
with a tab control on it, and two subforms - one on each page of the tab
control? and the subforms are both bound to the same table (tblClient)?

if the answers to the above questions are yes, then try the following code
in the continuous subform's Current event, as

Me.Parent!SubformBControlName.Form!ClientID = Me!ClientID

we'll consider that the continuous subform is SubformA and the "other"
subform is SubformB. in the code above, just replace SubformB with the
correct name of the subform control that contains the "other" subform.

hth
 
G

Guest

Let me give it another try. TabControl form and SubformA are both bound to
Client table. SubformA is a continuous form. I want to be able to click on a
command button in SubformA to select a ClientID and have that Client
displayed in the Tabcontrol form. When I try to do that using the code I
specified below, I get the message "You can't assign a value to this object."
 
T

tina

there's no such thing as a "Tabcontrol form", hon. you can put a tab control
on a form, just like you can put a textbox control or a listbox control or a
combobox control on a form. a tab control can't be bound to a field in a
table, though; it's basically used to add "real estate" to a form, providing
more space to work in by adding pages to the control.

so let's see if i understand your setup now. you have a main form bound to
tblClients. the main form has a tab control on it, and i'm guessing that the
fields from tblClients are bound to controls that are sitting on a page of
the tab control. a 2nd page of the tab control holds SubformA, which is a
continuous form which is also bound to tblClients. correct so far?

okay, i had to test it before i realized the obvious: you want to *find* a
record in the main form, not *create* one. i guessing that your ClientID
field is the table's primary key, and is an Autonumber data type - which is
a good thing, because it stopped you (and me, in my test) from making the
mistake of overwriting the primary key of an existing record. instead, try

Private Sub Form_Current()

On Error Resume Next
Me.Parent.Recordset.FindFirst "ClientID = " & Me!ClientID

End Sub

if ClientID is actually a Text data type, then change the syntax to

"ClientID = '" & Me!ClientID & "'"

also, in the main form, doublecheck the LinkChildFields and LinkMasterFields
properties of the subform control. Access may have automatically filled in
"ClientID" (sans quotes) in both properties; if so, remove it from both, the
two properties should be blank.

if you prefer to click a button on the subform to get the current record to
show on the main form, move the code from the subform's Current event to a
command button's Click event.

hth
 
G

Guest

Thanks for the help. It worked just great. I am a visitor from another
universe (IBM AS/400) and am trying to learn the ways and language of this
new universe. Thanks for your patience in "interpreting" my poor "Access
speak".
 

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