2 questions

  • Thread starter Thread starter Karen H
  • Start date Start date
K

Karen H

Hi there,

firstly, my main switchboard opens when db is opened. On
the load it sees if the user is logged in the 'users'
table. If not I want the 'unknown user' form to open up.
This works using if.. then domd.openform... but the main
swirchboard form always opens in front of the 'unknown
user' form. I want both forms open but the 'unknown user'
one open in front. How can I do this?

secondly, I 3 unbound text boxes on a form. If the user
enters something in all 3 text boxes then I want a control
to be enabled. I tried all sorts of combinations on all 3
of the txtbox events (on key down/enter/lost focus/etc) to
get it to work smoothly - but no joy. When the 3rd box is
typed into (they can do the boxes in any order), I would
like the ctrl enabled - I don't want them to have to exit
the txtbox first.

All help is really appreciated!

Karen
 
Karen,

Question 1)

You can close the Switchboard the condition passes to open the unknown form:

If (unknown user is logged on) then
Docmd.OpenForm "myFOrm"
Docmd.Close
End If

Question 2:

In the AfterUpdate event of each textbox you would place code like this:

If Isnull([Control1]) or [Control1] = "" then
[Button1].Enabled = True
ElseIf Isnull([Control2]) or [Control2] = "" then
[Button1].Enabled = True
ElseIfIsnull([Control3]) or [Control3] = "" then
[Button1].Enabled = True
Else
[Button1].Enabled = False
End IF

I didn't test this, but I think it will work. You can also try it on the
change event of each control, but you may have to say [Control1].Text to
refer to the value in a textbox

God Bless,

Mark A. Sam
 
Correction:

If Isnull([Control1]) or [Control1] = "" then
[Button1].Enabled = False
ElseIf Isnull([Control2]) or [Control2] = "" then
[Button1].Enabled = False
ElseIfIsnull([Control3]) or [Control3] = "" then
[Button1].Enabled = False
Else
[Button1].Enabled = True
End IF
 
It does work with the AfterUpdate events, but not with the Change events or
the KeyPress Events. It probably could be worked out to work as you press a
key, but I can't take the time to do it. The problem is knowing the content
of the field when pressing a key. It reads the last value until the control
is updated.

Maybe someone else can help there.

God Bless,

Mark A. Sam
 
Thanks very much for the thought, but neither work.

1)As I said, I want both forms open - the Main Switchboard
open in the background

2)I've tried combinations like this - It seems to always
require that you move focus away from the txtbox before it
will run your command - I want it to run the command as
soon as something is typed - I tried keydown too - no luck.

Any other thoughts anyone?? Thanks,

K
-----Original Message-----
Karen,

Question 1)

You can close the Switchboard the condition passes to open the unknown form:

If (unknown user is logged on) then
Docmd.OpenForm "myFOrm"
Docmd.Close
End If

Question 2:

In the AfterUpdate event of each textbox you would place code like this:

If Isnull([Control1]) or [Control1] = "" then
[Button1].Enabled = True
ElseIf Isnull([Control2]) or [Control2] = "" then
[Button1].Enabled = True
ElseIfIsnull([Control3]) or [Control3] = "" then
[Button1].Enabled = True
Else
[Button1].Enabled = False
End IF

I didn't test this, but I think it will work. You can also try it on the
change event of each control, but you may have to say [Control1].Text to
refer to the value in a textbox

God Bless,

Mark A. Sam


Hi there,

firstly, my main switchboard opens when db is opened. On
the load it sees if the user is logged in the 'users'
table. If not I want the 'unknown user' form to open up.
This works using if.. then domd.openform... but the main
swirchboard form always opens in front of the 'unknown
user' form. I want both forms open but the 'unknown user'
one open in front. How can I do this?

secondly, I 3 unbound text boxes on a form. If the user
enters something in all 3 text boxes then I want a control
to be enabled. I tried all sorts of combinations on all 3
of the txtbox events (on key down/enter/lost focus/etc) to
get it to work smoothly - but no joy. When the 3rd box is
typed into (they can do the boxes in any order), I would
like the ctrl enabled - I don't want them to have to exit
the txtbox first.

All help is really appreciated!

Karen


.
 
Karen,

Sorry, I misunderstood about the Main Switchboard. It sounds as though it
is a popup form. Open its property sheet and see if that is the case. Set
popup to no. The switchboard should not be a popup form. I control mine
with the MoveSise command as well as removing the Max button as well as
placing the line, DoCmd.Restore in the Activate event of the form.

I can't help you with the Keystroke matter right now, as time is an issue.
I thought I had worked that out in one of my apps, but don't know which. If
I can find it or work it out later, I will post it.

God Bless,

Mark




Karen H said:
Thanks very much for the thought, but neither work.

1)As I said, I want both forms open - the Main Switchboard
open in the background

2)I've tried combinations like this - It seems to always
require that you move focus away from the txtbox before it
will run your command - I want it to run the command as
soon as something is typed - I tried keydown too - no luck.

Any other thoughts anyone?? Thanks,

K
-----Original Message-----
Karen,

Question 1)

You can close the Switchboard the condition passes to open the unknown form:

If (unknown user is logged on) then
Docmd.OpenForm "myFOrm"
Docmd.Close
End If

Question 2:

In the AfterUpdate event of each textbox you would place code like this:

If Isnull([Control1]) or [Control1] = "" then
[Button1].Enabled = True
ElseIf Isnull([Control2]) or [Control2] = "" then
[Button1].Enabled = True
ElseIfIsnull([Control3]) or [Control3] = "" then
[Button1].Enabled = True
Else
[Button1].Enabled = False
End IF

I didn't test this, but I think it will work. You can also try it on the
change event of each control, but you may have to say [Control1].Text to
refer to the value in a textbox

God Bless,

Mark A. Sam


Hi there,

firstly, my main switchboard opens when db is opened. On
the load it sees if the user is logged in the 'users'
table. If not I want the 'unknown user' form to open up.
This works using if.. then domd.openform... but the main
swirchboard form always opens in front of the 'unknown
user' form. I want both forms open but the 'unknown user'
one open in front. How can I do this?

secondly, I 3 unbound text boxes on a form. If the user
enters something in all 3 text boxes then I want a control
to be enabled. I tried all sorts of combinations on all 3
of the txtbox events (on key down/enter/lost focus/etc) to
get it to work smoothly - but no joy. When the 3rd box is
typed into (they can do the boxes in any order), I would
like the ctrl enabled - I don't want them to have to exit
the txtbox first.

All help is really appreciated!

Karen


.
 
Thanks Mark... sorry if the last message was a bit sharp -
I didn't mean it to be, it was very kind of you to spend
time helping me, and I do appreciate it.

AfterUpdate does work - as long as you move away from the
txtbox that has been typed in - the event does not seem to
be actioned until then... If anyone can find the time I'd
really appreciate it.

The more critical problem I have is this code for the main
switchboard:

Private Sub Form_Update() - I've also tried Activate
If UserStatus = "Unknown User" Then
DoCmd.OpenForm "Unknown User"
End Sub

I want the main switchboard open in the background with
the Unknown User form open in the foreground - but it only
seems to do it the other way round.

Thanks so much guys.
 
Thanks Mark,

Neither of them are pop ups - it works fine if I run the
command by clicking a control on the main switchboard, but
if the VBA is held in the onload type events it seems to
force the Main switchboard to the front. Good luck with
your work, thanks for your time and suggestions.

K
-----Original Message-----
Karen,

Sorry, I misunderstood about the Main Switchboard. It sounds as though it
is a popup form. Open its property sheet and see if that is the case. Set
popup to no. The switchboard should not be a popup form. I control mine
with the MoveSise command as well as removing the Max button as well as
placing the line, DoCmd.Restore in the Activate event of the form.

I can't help you with the Keystroke matter right now, as time is an issue.
I thought I had worked that out in one of my apps, but don't know which. If
I can find it or work it out later, I will post it.

God Bless,

Mark




Thanks very much for the thought, but neither work.

1)As I said, I want both forms open - the Main Switchboard
open in the background

2)I've tried combinations like this - It seems to always
require that you move focus away from the txtbox before it
will run your command - I want it to run the command as
soon as something is typed - I tried keydown too - no luck.

Any other thoughts anyone?? Thanks,

K
-----Original Message-----
Karen,

Question 1)

You can close the Switchboard the condition passes to open the unknown form:

If (unknown user is logged on) then
Docmd.OpenForm "myFOrm"
Docmd.Close
End If

Question 2:

In the AfterUpdate event of each textbox you would
place
code like this:
If Isnull([Control1]) or [Control1] = "" then
[Button1].Enabled = True
ElseIf Isnull([Control2]) or [Control2] = "" then
[Button1].Enabled = True
ElseIfIsnull([Control3]) or [Control3] = "" then
[Button1].Enabled = True
Else
[Button1].Enabled = False
End IF

I didn't test this, but I think it will work. You can also try it on the
change event of each control, but you may have to say [Control1].Text to
refer to the value in a textbox

God Bless,

Mark A. Sam


"Karen H" <[email protected]> wrote
in
message
Hi there,

firstly, my main switchboard opens when db is opened. On
the load it sees if the user is logged in the 'users'
table. If not I want the 'unknown user' form to open up.
This works using if.. then domd.openform... but the main
swirchboard form always opens in front of the 'unknown
user' form. I want both forms open but the 'unknown user'
one open in front. How can I do this?

secondly, I 3 unbound text boxes on a form. If the user
enters something in all 3 text boxes then I want a control
to be enabled. I tried all sorts of combinations on
all
3
of the txtbox events (on key down/enter/lost
focus/etc)
to
get it to work smoothly - but no joy. When the 3rd
box
is
typed into (they can do the boxes in any order), I would
like the ctrl enabled - I don't want them to have to exit
the txtbox first.

All help is really appreciated!

Karen


.


.
 
Hi Karen

Q1 - please show the code you are using to open the unknown user form.


Q2 - here is some code you can use to toggle this other control - in my
example the control to be enabled/disabled is Command0. To use this, from
the form designer, select the three textboxes. With all three selected,
enter into the *Change* property the following:

=Togglebutton()

This function will use the *Text* property of the active control and the
Value property of all others to determine whether to enable/disable the
button. When typing into a control, the value property still maintains the
original value until focus leaves the control. The *typed* value is in the
Text property (which is only available while the control has focus).

Private Function ToggleButton()
If Me.ActiveControl.Name = "text1" Then
Me.Command0.Enabled = Not (Len(Me.Text1.Text & "") = 0 Or
IsNull(Me.Text3) Or IsNull(Me.Text5))
ElseIf Me.ActiveControl.Name = "text3" Then
Me.Command0.Enabled = Not (IsNull(Me.Text1) Or Len(Me.Text3.Text &
"") = 0 Or IsNull(Me.Text5))
ElseIf Me.ActiveControl.Name = "Text5" Then
Me.Command0.Enabled = Not (IsNull(Me.Text1) Or IsNull(Me.Text3) Or
Len(Me.Text5.Text & "") = 0)
End If
End Function


Here's
 
Thanks Mark... sorry if the last message was a bit sharp -

I didn't notice that it was sharp. You shouldn't have said anything. ;)

I just test opening a form on the Load event of my switboard, and that form
opened on top of the switchboard. You must have something else going on in
code on one of the forms, or possibly the switchboard is corrupted. If it
is an Acces switchboard, try renaming it and creating a new one.

I had a problem with a switchboard once which took an awfully long time to
open. Making a new one, corrected the problem.

God Bless,


Mark



news:[email protected]...
 
Karen H said:
Hi there,

firstly, my main switchboard opens when db is opened. On
the load it sees if the user is logged in the 'users'
table. If not I want the 'unknown user' form to open up.
This works using if.. then domd.openform... but the main
swirchboard form always opens in front of the 'unknown
user' form. I want both forms open but the 'unknown user'
one open in front. How can I do this?

secondly, I 3 unbound text boxes on a form. If the user
enters something in all 3 text boxes then I want a control
to be enabled. I tried all sorts of combinations on all 3
of the txtbox events (on key down/enter/lost focus/etc) to
get it to work smoothly - but no joy. When the 3rd box is
typed into (they can do the boxes in any order), I would
like the ctrl enabled - I don't want them to have to exit
the txtbox first.

All help is really appreciated!

Karen

Question 1:
I'd guess your problem is that running the code to open the other form
in the switchboard form's Open or Load event causes a timing problem,
where the switchboard hasn't been displayed yet when the second form is
opened. Try putting your code in the switchboard's Activate event.
Since this event will fire every time the switchboard gets the focus,
you may have to add some code to "turn it off" after the first time.

Question 2:
You probably have to use the Change event of each text box, and check
the .Text property of that text box as well as the .Value property of
the other text boxes. Unfortunately, that means you need separate code
for each text box. For example, suppose you have text boxes Text1,
Text2, and Text3:

'---- start of example event procedures ----
Private Sub Text1_Change()

Dim fEnableIt As Boolean

If Len(Me!Text1.Text) > 0 Then
If Not IsNull(Me!Text2) Then
If Not IsNull(Me!Text3) Then
fEnableIt = True
End If
End If
End If

Me!OtherControl.Enabled = fEnableIt

End Sub

Private Sub Text2_Change()

Dim fEnableIt As Boolean

If Len(Me!Text2.Text) > 0 Then
If Not IsNull(Me!Text1) Then
If Not IsNull(Me!Text3) Then
fEnableIt = True
End If
End If
End If

Me!OtherControl.Enabled = fEnableIt

End Sub

Private Sub Text3_Change()

Dim fEnableIt As Boolean

If Len(Me!Text3.Text) > 0 Then
If Not IsNull(Me!Text1) Then
If Not IsNull(Me!Text2) Then
fEnableIt = True
End If
End If
End If

Me!OtherControl.Enabled = fEnableIt

End Sub
'---- end of example event procedures ----
 
Thanks so much for your suggestions everybody.

Sandra,

2) Your code is great! I fiddled it a little but got it
working beautifully! Thanks

1) I tried recreating the form - no change. I also tested
it on a newly created form with just dosmd.openform.. on
the load event - and it worked fine! So it must be
something in this code. I have attached it here Sandra
(PS I have tried holding the docmd.openform code in the
activate bit and in a seperate sub in a seperate module -
no joy.) Here it is:

Private Sub Form_Load()

LoadAdministratorDetails

If GetScreenWidth < 800 Then
MsgBox "This database was designed to be viewed on
screen resolution 1024x768. " _
& "Your PC is set to " & GetScreenResolution & "
thus items may not be displayed properly. Contact " _
& AdministratorName & " for further
information.", , "Screen Resolution"

End If

Select Case UserStatus

Case "Administrator"
ctrlAdmin.Visible = True
ctrlDBwindow.Visible = True

Case "Private Outpatients"
CtrHosp.Enabled = False
CtrDQM.Enabled = False
CtrCon.Enabled = False
CtrMan.Enabled = False
CtrFin.Enabled = False
CtrThe.Enabled = False
ctrlAdmin.Visible = False
ctrlDBwindow.Visible = False

Case Else 'there will be more cases in future.
ctrlAdmin.Visible = False
ctrlDBwindow.Visible = False
If UserStatus = "Unknown User" Then
DoCmd.OpenForm "Unknown User"
Exit Sub

End Select

End Sub

Thanks so much! 1 down, 1 to go!

Karen

-----Original Message-----
Hi Karen

Q1 - please show the code you are using to open the unknown user form.


Q2 - here is some code you can use to toggle this other control - in my
example the control to be enabled/disabled is Command0. To use this, from
the form designer, select the three textboxes. With all three selected,
enter into the *Change* property the following:

=Togglebutton()

This function will use the *Text* property of the active control and the
Value property of all others to determine whether to enable/disable the
button. When typing into a control, the value property still maintains the
original value until focus leaves the control. The *typed* value is in the
Text property (which is only available while the control has focus).

Private Function ToggleButton()
If Me.ActiveControl.Name = "text1" Then
Me.Command0.Enabled = Not (Len(Me.Text1.Text & "") = 0 Or
IsNull(Me.Text3) Or IsNull(Me.Text5))
ElseIf Me.ActiveControl.Name = "text3" Then
Me.Command0.Enabled = Not (IsNull(Me.Text1) Or Len (Me.Text3.Text &
"") = 0 Or IsNull(Me.Text5))
ElseIf Me.ActiveControl.Name = "Text5" Then
Me.Command0.Enabled = Not (IsNull(Me.Text1) Or IsNull(Me.Text3) Or
Len(Me.Text5.Text & "") = 0)
End If
End Function


Here's

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.


Karen said:
Hi there,

firstly, my main switchboard opens when db is opened. On
the load it sees if the user is logged in the 'users'
table. If not I want the 'unknown user' form to open up.
This works using if.. then domd.openform... but the main
swirchboard form always opens in front of the 'unknown
user' form. I want both forms open but the 'unknown user'
one open in front. How can I do this?

secondly, I 3 unbound text boxes on a form. If the user
enters something in all 3 text boxes then I want a control
to be enabled. I tried all sorts of combinations on all 3
of the txtbox events (on key down/enter/lost focus/etc) to
get it to work smoothly - but no joy. When the 3rd box is
typed into (they can do the boxes in any order), I would
like the ctrl enabled - I don't want them to have to exit
the txtbox first.

All help is really appreciated!

Karen

.
 
Also, if it will be of any help - when the database is
opened to an unknown user (prompting the second form to be
opened), even though the Main Switchboard is shown on top,
it is the first window in the window menu, whilst
the "unknown user" form is 2nd (but not active).
-----Original Message-----
Hi Karen

Q1 - please show the code you are using to open the unknown user form.


Q2 - here is some code you can use to toggle this other control - in my
example the control to be enabled/disabled is Command0. To use this, from
the form designer, select the three textboxes. With all three selected,
enter into the *Change* property the following:

=Togglebutton()

This function will use the *Text* property of the active control and the
Value property of all others to determine whether to enable/disable the
button. When typing into a control, the value property still maintains the
original value until focus leaves the control. The *typed* value is in the
Text property (which is only available while the control has focus).

Private Function ToggleButton()
If Me.ActiveControl.Name = "text1" Then
Me.Command0.Enabled = Not (Len(Me.Text1.Text & "") = 0 Or
IsNull(Me.Text3) Or IsNull(Me.Text5))
ElseIf Me.ActiveControl.Name = "text3" Then
Me.Command0.Enabled = Not (IsNull(Me.Text1) Or Len (Me.Text3.Text &
"") = 0 Or IsNull(Me.Text5))
ElseIf Me.ActiveControl.Name = "Text5" Then
Me.Command0.Enabled = Not (IsNull(Me.Text1) Or IsNull(Me.Text3) Or
Len(Me.Text5.Text & "") = 0)
End If
End Function


Here's

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.


Karen said:
Hi there,

firstly, my main switchboard opens when db is opened. On
the load it sees if the user is logged in the 'users'
table. If not I want the 'unknown user' form to open up.
This works using if.. then domd.openform... but the main
swirchboard form always opens in front of the 'unknown
user' form. I want both forms open but the 'unknown user'
one open in front. How can I do this?

secondly, I 3 unbound text boxes on a form. If the user
enters something in all 3 text boxes then I want a control
to be enabled. I tried all sorts of combinations on all 3
of the txtbox events (on key down/enter/lost focus/etc) to
get it to work smoothly - but no joy. When the 3rd box is
typed into (they can do the boxes in any order), I would
like the ctrl enabled - I don't want them to have to exit
the txtbox first.

All help is really appreciated!

Karen

.
 
Hiya,

I managed to find a dodgy way around the problem: I think
it might have something to do with the main switchboard
being the startup form.

I switched it so that the Unknown User form was the
startup. Here is the code I put on the form load for the
Unknown User:

Private Sub Form_Load()
LoadUser
If UserStatus <> "Unknown User" Then DoCmd.Close
DoCmd.OpenForm "Main Switchboard"
End Sub

I hate it, but it's the only way I could get round the
problem. Tell me if you've figured it out please.

K x
 
Hi Karen,

I've tried a number of things but haven't found anything that works
consistently - I'll let you know if I come up with something better -
meanwhile glad you found something that works :-)
 
Back
Top