problem with macro

J

Jens Andersson

Hello,

I will try to describe my situation and my problem as
detailed as possible since noone has been able to help me
so far...
I have made an access-database with a userinterface, it is
used for visitor registration. When the user starts the
database i form called "start" is presented to the user,
from here I can choose to register "new visitor", search
and to print different types of reports. I have made a
form called "new visitor" where I can register a new
visitor. Everything works fine, and after registering a
new user I have made a button called "close", and if I
click the close-button I get back to the "start"-form. On
the start-form I have made a window where all the visitors
of the current day is visible, and the data is off course
linked to the form "new visitor". The function I would
like to have is, if I click on a visitor of the current
day in the window on the "start"-form I want to get up the
current user in the "new visitor" form, but I cant get
this to work. I have made a macro that opens the form "new
visitor" and tried every possible way to make it open the
record of the current user, but it always open the same
record (usually the first record in the database). So,
finally, my question is, how can I make a macro that opens
the record of the current user, (the one that I click).
A would really appreciate help on this one, since not a
single person so far has been able to help me.
 
S

Steve Schapel

Jens,

I presume you have a command button on the Start form for registering
a new visitor. If so, the macro assigned to this button's On Click
event can have the OpenForm macro action, nominate the New Visitor
form in the macro's Form Name argument, and set the macro's Data Mode
argument to Add.

As regards displaying the details of the selected visitor, it is
difficult to give specific advice without knowing specific information
about your data and your form. When you say a "window" displays the
current day's visitors, do you mean it is a continuous view subform?
If so, you can set your macro to the On Click event of the form, and
trigger the opening of the New Visitor form by clicking the record
selector next to the relevant visitor. Or you could use the On Click
or On DoubleClick event of any of the controls on the subform. Now
you need to have some way of specifying or identifying the visitor you
wish to see. The standard way of doing this in a database is for each
record to have a field which uniquely identifies each record, such as
a VisitorID field. Assuming you have such a thing, and assuming this
field is included in the New Visitor form and also the today's
visitors subform on Statrt form, you can use the Where Condition
argument of an OpenForm macro action. It would use this syntax... you
will need to substitute your own actual field and form names...
[VisitorID]=[Forms]![Start]![VisitorsTodaySubform]![VisitorID]

- Steve Schapel, Microsoft Access 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

Top