Passing variables between forms

  • Thread starter Thread starter Sandra
  • Start date Start date
S

Sandra

I have a main form with 2 subforms. When the main form
is first entered I have AllowEdits as False and this is
placed in On Current and AfterUpdate. I have an Edit
Command Button to switch AllowEdits to True when the user
needs to correct the record.

I have a combo box on the main form that switches the
user to one of the subforms depending upon the value
selected in the combo box.

My problem is that when the user switches to the subform
then back to the main form to complete, AllowEdits has
been switched back to False.

Is there a way to use some code as a switch so that when
you exit the subform the main form remains in the editing
mode?

Thanks for your help,

Sandra
 
Yes, I added a statement AllowEdits True in the
AfterUpdate Event of the subform, but I think the
AllowEdits False statement in On Current when returning
to the main form cancels this out.
It seems to me that I need some sort of If statement and
I was working on something like this:
On Current Event and After Update of main form
Dim MySwitch as Boolean
MySwitch = False
If MySwitch = False Then
Me.AllowEdits = False
Else Me.AllowEdits = True
End If
Then if the user hits the Edit button to edit on the main
form, then moves to the subform, I put in the Afterupdate
of the subform:
MySwitch = True

But this doesn't seem to work. Are variables passed on
to the procs in each form, or are they proprietary to the
procedure within the form. I'm just learning VB, and I
am having real struggles understanding how to use
variables.

Thanks,

Sandra
 
Sandra

It sounds like its doing what you told it, but what you told it ...

If you add a "breakpoint" to the code behind your form, then run your form,
you can use the single-step button to walk through each line of code. You
can use the immediate window to test/print values of your fields and
properties.

This is a standard debugging approach.

It sounds like you'll need to learn more about VB!
 
But this doesn't seem to work. Are variables passed on
to the procs in each form, or are they proprietary to the
procedure within the form. I'm just learning VB, and I
am having real struggles understanding how to use
variables.

Thanks,
here is some debugging / good programming help:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnacc2k/html/accs2000.asp
http://www.fontstuff.com/access/acctut17.htm
http://www.fmsinc.com/tpapers/vbacode/Debug.asp
http://members.iinet.net.au/~allenbrowne/ser-30.html

hth
Marc
 
Back
Top