Use Name Of Rectangle For Search

M

msinsabaugh

I am using Access 2007 and I've looked everywhere I can think of to find an
asnwer for this but to no avail. I have a form with a lot of rectangles on
it. I want to display data based on which rectangle is clicked by the user.
It seems to me as if the easiest way is to have the key field of the database
contain the name of a rectangle (Box100, Box101, Box102...). As an example I
have the rectangle name hard coded in (Box414 in this instance) but I would
like to have the event get the name of the rectangle clicked and use that as
the search criteria

DoCmd.OpenForm "DataEntry", , , "ID='Box414'"

Where "DataEntry" is the name of a data entry form
and "ID='Box414" is what I want to replace with the name of the rectangle.

I hope this makes sense. If someone can direct me where to look I would sure
appreciate it.
 
D

Daryl S

msinsabaugh -

I can't think of why you would use rectangles instead of maybe radio buttons
or a drop-list for this, but I imagine there must be a business reason for
this. If you want the user to click on any rectangle on the form and have it
open another form, passing in an argument, then it is pretty easy to do. You
have two choices, depending on how much is the same or different between the
rectangles.

Method 1:
On the OnClick event for each rectangle, put in the code you have,
substituting the literal you need for Box414, and if there are different
form, use the appropriate form for "DataEntry".

Method 2:
Create a form procedure that accepts values for the 'Box414' (and if needed
for the form name). This procedure will look something like this:

Public Subroutine OpenNextForm(strID as String, strFormName as String)

DoCmd.OpenForm strFormName, , , "ID='" & strID & "'"

End Sub

Then in the OnClick event for each rectangle, call this procedure with the
right values:

OpenNextForm("Box414","DataEntry")
 

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