Use vb code in a forms event procedure to open another form

G

Guest

I'm using Microsoft Access 2000. I want to use visual basic code in an event
procedure on one form to open a second form when the specified event occurs.
I've got it to open the second form, but you can't see any of the controls on
the form, it's just a blank screen. All the controls are set to visible, and
when I open form 2 seperately by itself it works fine, but when I try to
open it from the event procedure it doesn't work right.

Any suggestions?
 
G

Guest

Is it possible that this event starts to run some other heavy code afterwards
or gets in a loop?

Because then Form 2 has no time to refresh it's controls

- Raoul
 
D

Dirk Goldgar

rg32 said:
I'm using Microsoft Access 2000. I want to use visual basic code in
an event procedure on one form to open a second form when the
specified event occurs. I've got it to open the second form, but you
can't see any of the controls on the form, it's just a blank screen.
All the controls are set to visible, and when I open form 2
seperately by itself it works fine, but when I try to open it from
the event procedure it doesn't work right.

Any suggestions?

Are you applying any criteria to the form when you open the form from
code? Is the form read-only, or does its query nonupdatable? If a form
has no records to display, and no records can be added via the form
(either because the form doesn't allow additions or because the form's
recordset is not updatable), then the form's detail section will be
completely blank.
 
G

Guest

I'm wanting this to be a blank form (based on an existing form) which can be
used for adding a new record to the database. I've discovered that if I
chose to open the form in Edit mode it works correctly, but then it displays
all the records. I was trying to open it in Add mode so that it could only
be used to add a new record only, not edit or view any existing records, but
then the controls don't show up. Is there a way around this?
 
D

Dirk Goldgar

rg32 said:
I'm wanting this to be a blank form (based on an existing form) which
can be used for adding a new record to the database. I've discovered
that if I chose to open the form in Edit mode it works correctly, but
then it displays all the records. I was trying to open it in Add
mode so that it could only be used to add a new record only, not edit
or view any existing records, but then the controls don't show up.
Is there a way around this?

When you open the form in Edit mode, can you add a new record on the
form? Did you check? (because I'm inclined to doubt that you can) Can
you modify data in existing records?
 
G

Guest

No, you are right, although the form shows up, it does not work correctly. I
was so happy to actually see it show up that I didn't even test it.

The form does work correctly when it is opened by itself directly from the
Data Base window, and it also works opening it with a macro. But if I use
the macro in the event procedure, or use either the Run Macro command or the
Open Form command in VB it doesn't work right. I've tried all the ways I can
think of.

Since the form works by itself, I'm beginning to think it may have something
to do with the way the 1st form is set up, or the connections between the 2
forms, but I've checked and rechecked everything I can think of and don't
have a clue what could be causing the problem. I've used this method to open
regular forms before without any problems- the only thing different is that
I'm using the "NotInList" event for a combo box, and only want the form in
"Add New Record" mode
 
D

Dirk Goldgar

rg32 said:
No, you are right, although the form shows up, it does not work
correctly. I was so happy to actually see it show up that I didn't
even test it.

The form does work correctly when it is opened by itself directly
from the Data Base window, and it also works opening it with a macro.
But if I use the macro in the event procedure, or use either the Run
Macro command or the Open Form command in VB it doesn't work right.
I've tried all the ways I can think of.

Since the form works by itself, I'm beginning to think it may have
something to do with the way the 1st form is set up, or the
connections between the 2 forms, but I've checked and rechecked
everything I can think of and don't have a clue what could be causing
the problem. I've used this method to open regular forms before
without any problems- the only thing different is that I'm using the
"NotInList" event for a combo box, and only want the form in "Add New
Record" mode

I think you'd better post the event procedure that opens the form.
 

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

Top