Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

show box on form open based on combo box 2

Status
Not open for further replies.

DrSmyth

Technical User
Jul 16, 2003
557
0
0
GB
I've a form with some code in the open routine:
Code:
Me.Box89.Visible = True
Forms![Referrals Edit]![ReferralType].SetFocus
If Me.ReferralType.Text = "Premier Service Managers" Or Me.ReferralType.Text = "FPM" Or Me.ReferralType.Text = "AFSM" Or Me.ReferralType.Text = "Financial Planning Direct" Then
Me.Box89.Visible = False
Else: Me.Box89.Visible = True
End If

basically i have some commands behind 'Box89' that i want hidden if certain text is not present in a text box on the form. This works fine if i'm accessing the form to edit a current record (using this code:
Code:
    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "Referrals Edit"
    
    stLinkCriteria = "[Beneficiary Name]=" & "'" & Me![search_bene] & "'"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
)

whereas if i'm accessing the form to add a new record (using this code
Code:
    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "Frm_InputCaseholder"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    DoCmd.GoToRecord , , acNewRec
)

it does not hide the box (box89)despite the text box meeting the relevant criteria.

Can anbody help?


it doesn't work
 
Have you tried putting code in the ReferralType OnChange event?

Also, you dont have to set the focus to the textbox if you use .Value.

Code:
If Me.ReferralType.Value = "Premier Service Managers" Or Me.ReferralType.Value = "FPM" Or Me.ReferralType.Value = "AFSM" Or Me.ReferralType.Value = "Financial Planning Direct" Then
     Me.Box89.Visible = False
Else
     Me.Box89.Visible = True
End If

-Pete
 

SYNPERX3 has a good question/suggestion.

I'm inclined to suggest, depending on what the form is doing and when, that you might want to examine the form's ON CURRENT property.

Esentially, that property (code attached, of course) runs whenever the record changes.

I don't know ... this is a little perplexing. I'll check back to find out a better answer later.

You might want to touch base with a Tek-Tips user, MajP ... that guy's really good.

Alan J. Volkert
Fleet Services
GE Commercial Finance Capital Solutions
(World's longest company title)
Eden Prairie, MN
 
Hi snyperx3,

I've got some code running from the ReferralType OnChange event, but it isn't invoked when i open the form (presently). I'll take a look at the oncurrent event, see if there's anything there that can help me..

Cheers guys I'll let you know how i get on...
 
Hi avolkert, i added the code to the oncurrent event and it now seems to work, thanks for the pointer. You can have a star.

Also a star for you snyperx3 as the code seems much neater using the .value property as opposed to the .text

Thanks for the help folks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top