OpenForm?

F

Frank

Hi all,
I have 2 Forms, Form1 (with Devices) and Form2 (with Components).
In the Form1 I have got list of Devices (with ID_Device, the field name
txtDevice). I have got list with 70 devices, when I click on the ID_Device
(1,2,3,etc) i I'd like open Form2 related on the ID_Device from Form1. I'd
like see only this Compoment wchich i choose in the Form1.
I am using Access 2007 and i try write OpenForm in VBA and i always fail.
Please help me.
 
E

ErezM via AccessMonster.com

hi Frank
if every time you choose the device in form1, form2 is closed, then you can
use in deviceID click event on form1:

DoCmd.OpenForm "form2", , , "DeviceID=" & DeviceID

but this will work only if form2 is closed when the "DoCmd.OpenForm" is
called.
if it's open (you have both form1 and form2 open side by side), then you need
to change form2's filter instead, using the same click event in form1:

Forms!form2.Form.Filter="DeviceID=" & devicerID
Forms!form2.Form.FilterOn=True

good luck
Erez
 
F

Frank

Hi,
when I use:
DoCmd.OpenForm "form2", , , "DeviceID=" & DeviceID
Form2 will open but all with every Components, not reletated with ID_Device
from Form2.

Any idea?
 
E

ErezM via AccessMonster.com

hi
put a break point on the OpenForm line and check DeviceID variable to see the
value that is passed as a filter
if the value is right, make sure DeviceID is present on form2
also make sure there is no code runnig when form2 is opened (that might
change the filter)

Erez
Hi,
when I use:
DoCmd.OpenForm "form2", , , "DeviceID=" & DeviceID
Form2 will open but all with every Components, not reletated with ID_Device
from Form2.

Any idea?
hi Frank
if every time you choose the device in form1, form2 is closed, then you can
[quoted text clipped - 21 lines]
 

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