Quicky Syntax on Visible For Subform

M

MBoozer

Can someone please provde me with the right syntax on the following code. I
am trying to visible.NotVisible a subform(MSDSDocsTabUserSearch) on a
subform(Suppliers) on my main form(UserSearch). Code on the main form
(UserSearch) oncurrent property is as follows:

Forms!UserSearch.Form.Suppliers.MSDSDocsUserSearch.Visible =
(Forms!UserSearch.Form.Suppliers.MSDSDocsUserSearch.Form.RecordsetClone.RecordCount > 0)

Thanks!
 
A

Albert D.Kallal

You can use

Dim f As Form

Set f = Me.suppliers.Form.MSDSDocsUserSeach.Form

If f.RecordsetClone.ReocrdCount > 0 Then
f.Visible = True
Else
f.Visible = False
End If
 
T

tina

try

Me!Suppliers!MSDSDocsUserSearch.Visible =
(Me!Suppliers!MSDSDocsUserSearch.Form.RecordsetClone.RecordCount > 0)

the above assumes that 1) the code is running from the main form, *not* from
the Suppliers subform or the MSDSDocs...Search sub-subform; and 2)
"Suppliers" and "MSDSDocsUserSearch" are the correct names of the subform
controls - as listed in each subform's parent form.

hth


MBoozer said:
Can someone please provde me with the right syntax on the following code. I
am trying to visible.NotVisible a subform(MSDSDocsTabUserSearch) on a
subform(Suppliers) on my main form(UserSearch). Code on the main form
(UserSearch) oncurrent property is as follows:

Forms!UserSearch.Form.Suppliers.MSDSDocsUserSearch.Visible =
(Forms!UserSearch.Form.Suppliers.MSDSDocsUserSearch.Form.RecordsetClone.Reco
rdCount > 0)
 
M

MBoozer

Thanks Al and Tina. I get an application error on Al's code on the following
line:
Set f = Me.Suppliers.Form.MSDSDocsUserSeach.Form
I tried Tina's suggestion and it works (makes the subform NotVisible)
however it makes it not visible all the time when I know that out of the 3
test records I have in the dbase, two of them should be showing up. Any ideas?
 
M

MBoozer

I tried it Tina. The code is the same as you the one you suggested before.
Still doesn't work and the subform names are correct.
 
S

Shane S via AccessMonster.com

Hey MBoozer,

I hope I'm following correctly but I think you need to do a little
rearranging. Try:

Forms!UserSearch!Suppliers.Form!MSDSDocsUserSearch.Form.Visible =
(Forms!UserSearch!Suppliers.Form!MSDSDocsUserSearch.Form.RecordsetClone.
RecordCount > 0)

HTH,
Shane
 
A

Albert D.Kallal

Thanks Al and Tina. I get an application error on Al's code on the
following
line:
Set f = Me.Suppliers.Form.MSDSDocsUserSeach.Form

Hum...you could try

Set f = Me.Suppliers.Form!MSDSDocsUserSeach.Form
 
T

tina

I tried it Tina. The code is the same as you the one you suggested before.
Still doesn't work and the subform names are correct.

okay. you posted the following in response to Albert's first post in this
thread:
I tried Tina's suggestion and it works (makes the subform NotVisible)
however it makes it not visible all the time when I know that out of the 3
test records I have in the dbase, two of them should be showing up.

so is this the result you're currently getting, or is it just flat not
working *at all* now? it's important to know, because if the code IS setting
the Visible property of the sub-subform to False, then we know the
references in the code are correct. so then the problem is that we're not
getting the correct count from the RecordsetClone. if that's the case, you
might try

With Me!Suppliers!MSDSDocsUserSearch
.Form.RecordsetClone.MoveLast
If .Form.RecordsetClone.RecordCount > 0 Then
.Visible = True
Else
.Visible = False
End If
End With

or you could declare all the references in full, as

Me!Suppliers!MSDSDocsUserSearch.Form.RecordsetClone.MoveLast
Me!Suppliers!MSDSDocsUserSearch.Visible =
(Me!Suppliers!MSDSDocsUserSearch.Form.RecordsetClone.RecordCount > 0)

i didn't mention it before, but of course the "....Visible =
(Me!Suppliers..." expression all goes on one line in the VBA procedure. (i
figure you already knew, but since we're having trouble getting it to work,
better to make sure we're all on the same page. :) )

hth
 
M

MBoozer

Thanks Tina and Shane. I tried your last suggestion as well Tina and also
could not get it to work but Shanes did. I kept getting a "can't find field
Suppliers" error or an "object not supported" error. All works fine now.
Thanks to both of you.
 
S

Shane S via AccessMonster.com

Your welcome. Glad you got it going and that I could help.

Shane
Thanks Tina and Shane. I tried your last suggestion as well Tina and also
could not get it to work but Shanes did. I kept getting a "can't find field
Suppliers" error or an "object not supported" error. All works fine now.
Thanks to both of you.
Hey MBoozer,
[quoted text clipped - 17 lines]
 

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