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!

Need help to automate selection of a form 1

Status
Not open for further replies.

VicLavigne

Technical User
Aug 10, 2003
14
0
0
US
Here's what I need to do: based on the value of a field on my startup form ( this is [Forms]![Welcome]![Text7] and is a number) I'd like to have an automatic selection of the next form to open. So far, I have that the startup form (Welcome) automatically closes on timer, but I can't work out a method for the next form to be selected.

Big caveat: I don't know VB, I have been using macros and expression builder. And this is Access 97.
 
Jump right into VB. You could use a combo box and on the click event
public sub combo0_click()

select case Me.combo0
1
docmd.openform "frmOne"
2
DOCmd.openform "frmTwo"
3
DoCmd.openform "frmThree"

end case

exit sub
 
Sorry, too early in the a.m. This is the form of the CASE

Select Case Me.List13
Case "one"
MsgBox "One"
Case "Two"
MsgBox "Two"
Case "Three"
MsgBox "Three"
End Select

Rollie E
 
Here's what I need to do: based on the value of a field on my startup form ( this is [Forms]![Welcome]![Text7] and is a number) I'd like to have an automatic selection of the next form to open. So far, I have that the startup form (Welcome) automatically closes on timer, but I can't work out a method for the next form to be selected.

Several suggestions based on your question...

1. Macros have a place, but if you ever plan on doing more, your best bet is to learn VBA. There is much more you can do with it.

2. I have a feeling that you used the Start Up wizzard to create your Welcome form. Best bet here is to create your own form, from scratch, and make it your start up. Once completed, you could have some buttons allowing a user to choose what they want. You can have security, which only allows those chosen to use certain forms.

3. If your Start Up has a timer, which in itself is not bad, what do you have on that form that will allow a user to choose where they want to begin?? What happens when to Welcome closes and a user hasn't chosen where to go?


Sorry I can't give a direct answer, but to me, the question is somewaht ambiguous.

HTH

An investment in knowledge always pays the best dividends.

by Benjamin Franklin
 
mph1:
No, I didn't use a wizard to create the Welcome form, I created it from scratch. The purpose of this initial startup was to greet the user, and provide a starting area to proceed to the next usuable form. The Welcome form has no input by the user, other than an Exit. I wanted something automatic that would choose the next form for the user. Depending on who logs on, they get a different starting form (the starting form being the next form after the Welcome).

I realize VB is probably the way to go, but I don't know anything about it.
 
Although I have never done exactly what you want, it sounds like a good idea.

Assuming the log in form has two fields (in this order), User Name and Password, you can put an IF statement in the On Exit of Password. Have it refer to the table where the user name and password are located. Unfortunately, it's been quite some time since I used a macro that I can't specifically tell you how to do using a mocro only.

Concept --- in the On Exit of the password you want to make sure that the user name agrees with the password. At that point, you want to issue a command (macro) to open a specific form which is determined by the user name and password.

As for learning VBA, you could try the following

In addition to this site, there are others and many good books that teach and have examples.

It has been my experience on this forum and others that those replying (offering help) normally use code in their explanation.

HTH


An investment in knowledge always pays the best dividends.

by Benjamin Franklin
 
Thanks for the suggestions. I think I'll study up on VB. In the meantime, it would just be simplest to add some command buttons to the Welcome screen and adjust the security settings accordingly. This will work, but isn't as aesthetically pleasing.
 
Rollilee:
It's automated, or more precisely, its calculated based on the CurrentUser().
 
Vic,
How does the program determine who that user is?

Rollie E

What I am getting at is, that information can be used to trigger your forms.
 
I was using the Expression Builder, and used IFF to set the value of a textbox based on CurrentUser() status. Like this:

(IFF CurrentUser()="Admin", 1,0) +
(IFF CurrentUser()="Victor", 2,0) +
(IFF CurrentUser()="Mary", 3,0)

So that Text5 would = 1 if Admin logged on, but would =0 if it wasn't Admin. If Victor logged on, then Text5 would = 2.

But that's as far as I could go with this, I can set the value of a field based on current user, but I couldn't see a way of automating opening a new form from there.
 
You are most of the way there. Now do the select case



SELECT CASE me.text5

CASE 1
DOCmd.openform "frmAdmin"
CASE 2
DoCms.openform "frmVictor"
case 3
DoCmd.openform "frmMary"
end SELECT


Rollie E
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top