image selection determines control

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi people, hope someone can lend me a hand.

I have hundreds of images/buttons on a form which each represent a unique
field in a record of a table. I want to be able to click on an image and this
will open a new form which will list the information for that record from the
table and two other tables which a related by the same field.(i will probably
put these in subforms).

I'm not sure how to get the new form to look up only the one record for the
image i selected, without prompting the user.
 
If you use the Tag property of the individual buttons to store the unique ID
of each table field, you can use it as the 'where' part of the docmd.OpenForm
argument, eg;

Private Sub Command1_Click()
DoCmd.Openform "DisplayFormNameHere", , ,"TableIDField = " & Me.Command1.Tag
& ""

TonyT..
 
Thanks for your help!

My code now shows:

Private Sub ImageIF330_Click()
DoCmd.OpenForm "IF330", , , "IF330 = " & Me.ImageIF330.Tag & ""
Exit_ImageIF330_Click:
Exit Sub
End Sub

Is TableIDField the name of the field containing the unique ID or the actual
Unique number/name?

At the moment this code dosen't work, it shows syntax error (missing
operator) in expression "IF330 = "

Once I get this command to open my blank form. How can I display for example
a subform from a different table, and it automatically find the records
associated with that unique ID? I assume i need to get it to use the tag? I'm
not sure how I would do this.

Thanks a lot for helping a stupid access user.
 
Hi again,

DoCmd.OpenForm "IF330", , , "tblIDFieldLineValue = " & Me.ImageIF330.Tag & ""

tblIDFieldLineValue = the actual reference number or text that forms the
Unique key field value for the record line you want to display. If this field
contains letters or numbers and letters then use;

DoCmd.OpenForm "IF330", , , "tblIDFieldLineValue = '" & Me.ImageIF330.Tag &
"'"

You appear to be trying to open a form called IF330, does this mean that you
are trying to open a different form for each image, or is the display form
called IF330?

If your subform is showing data from a child table to the main form, then
the subform should automatically show only the related records when you open
it, if it doesn't try a .requery in the On Load event.

Hope this helps some more,

TonyT..
 
Yeah its going to be the same form for all the images. I've just used the
same name for now. I'll change it after.

How would I set up my subform? set the source as the first form (with images
on)? or the table I want the information from?

Its currently (on clicking the image) opening my new form and bringing up
all information from a table in my subform. How do i get the subfrom to only
bring up info for the image we clicked? I've no 'HELP' on the Access i've got
access to, otherwise i'd dig into this .requery more.

thanks a lot mate

Simon
 
Thanks mate

I'm sorry if I'm missing something really obvious.

When I click on my image on the first form. I'm promted to enter data, then
my new form (IF330) opens with the subform on it. This time blank.

I've set the new form source to a table - service ( i want the subform to
show information from) and the child and master fields of the subform i've
put as a field in the table - service with 'source object' as table.service.

Do you know what's wrong?

Cheers
 
If you use the 2 data field references in the data tab of properties of the
subform (from the main form), Link Child Fields & Link Master Fields to link
the Main form and Sub form (based on a common refrence ID of similar), the
subform will automatically be updated to reflect any changes made in the main
form, no requery required.

TonyT..
 
sunrunner said:
Thanks mate

I'm sorry if I'm missing something really obvious.

When I click on my image on the first form. I'm promted to enter data, then
my new form (IF330) opens with the subform on it. This time blank.

I've set the new form source to a table - service ( i want the subform to
show information from) and the child and master fields of the subform i've
put as a field in the table - service with 'source object' as table.service.

Do you know what's wrong?

If the information you want to display on both the Main form and the Subform
are from the same table, you may well not actually need a subform, you could
perhaps just put all the data on the one form to make life easier, if however
they aren't from the same table or you can't do it that way then;

The linkMasterField, must be then name of a field in the recordsource of the
main form, OR a name of a control in the Main form. For example, If the main
form has a field called ServiceID, and you want to display all the records
related to ServiceID from another table called ServiceInfo, with the foreign
key to the Service table of ServiceInfoServiceID then your LinkChieldField
would be ServiceInfoServiceID and the LinkMasterField would be ServiceID.
Basically, just make suer that the Master and Child fields actually appear in
the Recordsource for each form.

Hope that clarifies it rather than complicating it even more :p

TonyT..
 
Each image on the main form represents a location. im using a subform,
because there is more than one record for each location. i i want to view
them all in a list.

I have set the recordsource of the new form which i've name LOOKUP to
table.service. then i have set my subform source to table.service. in the
service table, there is a field called Conveyor Position. So i have selected
this as the master and child link field in the subform.

but when i click an image on my main form, i am prompted to enter the
conveyor position before my new form LOOKUP (with the subform on it) opens,
and then it dosn't even bring any records up in the subform for that conveyor
position.
 
Hi again,

Sometimes it's easier to create 2 queries, one for the main form and another
for the subform - make sure both contain the linking field (conveyor), when
you have them both displaying the data you requier, use them as the data
source for each form, that way you can actually see the records produced by
each recordset.

TonyT..
 
Hi mate

thanks again!!

I've got three subforms on the main form. ive made a query 'queryLOOKUP'
with just a link to table.conveyorpostion and output as Conveyor Position.
then i've set up a query for each of the subforms, for example:
'servicequeryLOOKUP' with table.conveyorposition and table.service output as
the fields i want to see in the subform. the subforms are still link by child
and master fields. when i click on my image, i am prompted to enter a
location. then my main form 'LOOKUP' opens but the subforms are blank. what
am i missing?

Cheers mate
 
Back
Top