Code from earlier post

T

tracey

I have included the code as requested. In the previous
response some one suggested cancel= true. I don't
understand?
Thanks

Private Sub Form_Open()
If Me.TableLink = 0 Then 'checks refresh for false
cmdNav_Click ' this runs the proc wich refreshes tables
Me.TableLink = -1 ' updates the refresh to true
DoCmd.Close acForm, Me.Name 'closes this form
DoCmd.OpenForm "frmLogin", acNormal 'opens the login
form

Else 'if the ref is true then close form and open login
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "frmLogin", acNormal
End If
End Sub
 
G

Graham Mandeno

Hi Tracey

The Form_Open event procedure should be declared with an argument, like
this:

Private Sub Form_Open(Cancel as Integer)

If you set Cancel to a non-zero value in the procedure, then the Open event
will be cancelled, which prevents the form from opening. So instead of
DoCmd.Close..., you just need Cancel = True.
 
M

Marshall Barton

tracey said:
I have included the code as requested. In the previous
response some one suggested cancel= true. I don't
understand?
Thanks

Private Sub Form_Open()
If Me.TableLink = 0 Then 'checks refresh for false
cmdNav_Click ' this runs the proc wich refreshes tables
Me.TableLink = -1 ' updates the refresh to true
DoCmd.Close acForm, Me.Name 'closes this form
DoCmd.OpenForm "frmLogin", acNormal 'opens the login
form

Else 'if the ref is true then close form and open login
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "frmLogin", acNormal
End If
End Sub


I don't follow what you're trying to do, probably because
that info is in a different thread. Please post your
followup questions as replies to your original question.

The form's Open event is too early for its controls to have
values. You have to wait until at least the Load event.
 

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

Similar Threads


Top