By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,439 Members | 1,891 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,439 IT Pros & Developers. It's quick & easy.

Help with 'Conditional commands'

P: 32
I have a FORMA with a BUTTON1 which opens FORMB based on the value of PORTID field as a setlink criteria.

If No record is found during setlinkcriteria, then I would like the PORTID value of FORMA to update(copyto) only 1 of the following fields in FORMB (creating new record): PORTA or PORTZ. In order to deterrmine which field (PORTA or PORTZ) gets updated depends upon the value in the CATEGORY field found in FORMA. The value in CATEGORY would compare against an existing "text1" and "text2" I have in the code portion of the form.

Additionally, FORMB has 2 subforms. SUBFORMPORTA shows current selection for PORTA. And SUBFORMPORTZ shows current record selection for PORTZ.

If, There is no value entered into PORTA I dont want the SUBFORMPORTA table to be visible. Likewise if PORTZ has no value entered, I dont want SUBFORMZ to appear.

FORMA (form)
PORTID (field)
CATEGORY (field)

FORMB (form)
PORTA (field)
PORTZ (field)

Please Advise, thanks
May 29 '07 #1
Share this Question
Share on Google+
5 Replies

Expert Mod 10K+
P: 12,374
What have you tried so far?
May 30 '07 #2

P: 32
The below appears in 'on Current' in properties of FORMB

Private Sub Form_Current()
With Me![SubformportA].Form
If .RecordsetClone.RecordCount = 0 And Forms!FORMA![Category] = "Server" Then Me![PortA] = Forms!FORMA![PortID] Else .Visible = (.RecordsetClone.RecordCount > 0)
End With

With Me![SubformportZ].Form
If .RecordsetClone.RecordCount = 0 And Forms!FORMA![Category] = "Switch" Or Forms!FORMA![Category] = "raritan" Then Me![PortZ] = Forms!FORMA![PortID] Else .Visible = (.RecordsetClone.RecordCount > 0)
End With
May 30 '07 #3

Expert Mod 10K+
P: 12,374
Does this work? If not, is it doing anything at all?

In addition to on current you'll want to put code in the after update event of porta and portz.
May 30 '07 #4

P: 32
It updates the PortA and PORTZ fields as it should, but subforms do not appear at all.

I only want the subform (PORTA or PORTZ) with a value > 0 to appear.
For some reason that doesnt happen.
May 30 '07 #5

Expert Mod 10K+
P: 12,374
Okay, I took a look at the code. You're using Me!Subform.Form.Visible When you should be using Me!Subform.Visible.
May 30 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.