Module for all Identical Forms

A

Allen Yap

I have 18 forms, all having identical controls. In each form module I have
the following codes examples
''''
Private Sub lbl1_DblClick(Cancel As Integer)
Dim noshow
noshow = Me!lbl1eg.Value
If IsNull(noshow) Then
MsgBox "No example", , "EG"
Exit Sub
End If
Me!lbl1.FontSize = 8
Me!lbl1.Height = 220
Me!lbl1.Move 1500, 550
Me!lbl1eg.Visible = True
End Sub

Private Sub lbl1eg_DblClick(Cancel As Integer)
DoCmd.GoToControl "lbl1"
Me!lbl1.FontSize = 16
Me!lbl1.Height = 800
Me!lbl1.Move 900, 800
Me!lbl1eg.Visible = False
End Sub
.............
................

The above is obviously not the best way. How do I create a Public Sub so
that each form can read from it. Please help

Thanks
 
J

John W. Vinson

The above is obviously not the best way. How do I create a Public Sub so
that each form can read from it. Please help

I really have to ask: WHY would one EVER have 18 identical forms!?

That said... you can put your code in Public Functions (not Subs) in a
Module; they'd be of the form

Public Function Functionname(ctl As Control)

....
ctl.Visible = False
....

in the Doubleclick event of each control put

=Functionname(Form.controlname)

Note it's Form not Forms.

John W. Vinson [MVP]
 
A

Allen Yap

Hi John,

Thanks for the reply, I will relook at my program again to see if I really
must have 18 identical forms.

I actually have a form with a subform serving as a task pane. Selecting a
label in the task pane will make visible 18 labels that links to each of the
identical forms. Each form reads a row of record from TBL_product.

I suppose I can use just one form that can jump to the desired row in the
TBL by anchoring on the primary key. Can you or anyone assist me with this
code. Appreciate a complete code for the job as I am really too distance from
being good in Access.

Regards

AY
 
K

KillMeTwice

Hi John,

Thanks for the reply, I will relook at my program again to see if I really
must have 18 identical forms.

I actually have a form with a subform serving as a task pane. Selecting a
label in the task pane will make visible 18 labels that links to each of the
identical forms. Each form reads a row of record from TBL_product.

I suppose I can use just one form that can jump to the desired row in the
TBL by anchoring on the primary key. Can you or anyone assist me with this
code. Appreciate a complete code for the job as I am really too distance from
being good in Access.

Regards

AY











- Vis sitert tekst -

The best way to learn this is by making a combobox!? Make a combobox
which finds a record from what you choose. Look at this code to learn
how to go to a spesific record. I could write you an example, but it
is easier for you if you do it with your form and table.
 
J

John W. Vinson

Hi John,

Thanks for the reply, I will relook at my program again to see if I really
must have 18 identical forms.

I actually have a form with a subform serving as a task pane. Selecting a
label in the task pane will make visible 18 labels that links to each of the
identical forms. Each form reads a row of record from TBL_product.

I suppose I can use just one form that can jump to the desired row in the
TBL by anchoring on the primary key. Can you or anyone assist me with this
code. Appreciate a complete code for the job as I am really too distance from
being good in Access.

Don't confuse FORMS with the data *displayed on* those Forms.

If you have 18 records, or 180 records, or 180000 records - you can
view any of them with just one form. The Combo Box Wizard gives you
the option of creating a combo box which will find a particular
record; you wouldn't want to use that method with 1800000 records, of
course, but for 18 it should be just fine.

Just put a Combo Box (using the wizard) on your form - maybe in the
form Header, or just in some conspicuous place - to allow the user to
select which Product should be displayed on the form.

I obviously cannot write you code to do it because I cannot see your
database, and don't know anything about it...

John W. Vinson [MVP]
 
A

Allen Yap

Hi John,

Thanks again for the comments.

I had used a single form to view any row of records using ApplyFilter. The
problem I am facing is with the "Image". Every record must carry a different
Image I can only do it with multiple forms. Using a single form does not
work. There is no "field" in table that can capture this.

Is there a way I can send you a snap shot.

Thanks

Regards

AY
 
A

Allen Yap

Hi John,

Thanks for your help and your thoughts generation comments. I took all your
pointers and relooked into my program. Now I can use only a single form for
the job. How did I missed out the "OLE Object field" in Table design?.

By the way I am still interested to know how a form can take
values/procedure from Module as in my earlier question.

Thanks also to Wayne-In-Manchester who contributed to another access user on
OLE object.

Regards

AY
 
J

John W. Vinson

How did I missed out the "OLE Object field" in Table design?.

It's a bit obscure, and not instantly obvious that it's a solution for
displaying images! Glad you found it.
By the way I am still interested to know how a form can take
values/procedure from Module as in my earlier question.

Missed that thread. Care to repost the question?

John W. Vinson [MVP]
 

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

MS Access Progress Bar 3
Custom class does not capture event 0
Blank Fields in Report 2
Required data in a form 1
DoCmd.GoToControl 10
Audit Trail 8
On Exit Event 2
AfterFinalRender 3

Top