Command Button to Specific Record

M

Mike

Good day Access Gurus! I have a form in which contains a command button that
opens another form in which the user inputs data into and then in turn closes
the second form only to select the "refresh" button on the first form to
update a combo box list.

1. How do I code the command button on the first form to go directly to the
related record on the second form when searching for a record?

2. How do I set some sort of update/refresh on the first form when I update
and close the second form?

Please let me know if more information is needed? Thanks!
 
C

Carl Rapson

Mike said:
Good day Access Gurus! I have a form in which contains a command button
that
opens another form in which the user inputs data into and then in turn
closes
the second form only to select the "refresh" button on the first form to
update a combo box list.

1. How do I code the command button on the first form to go directly to
the
related record on the second form when searching for a record?

2. How do I set some sort of update/refresh on the first form when I
update
and close the second form?

Please let me know if more information is needed? Thanks!

1. Use the WhereCondition parameter of the OpenForm call. If, for example,
your second form is bound to a table or query with a field named ID, you
could open the form positioned to a specific record like this:

DoCmd.OpenForm "form name",,,"[ID] = " & id_value

2. Use the acDialog option in your OpenForm call, then right after the
OpenForm call, do your refresh:

Me.cboBox.Requery


Carl Rapson
 
M

Mike

Hey Carl, thanks for responding. I got number 1 ok but I'm a little
uncertain on how to complete number 2. Could you be a little more specific
or maybe just more in lame terms?

Mike

Carl Rapson said:
Mike said:
Good day Access Gurus! I have a form in which contains a command button
that
opens another form in which the user inputs data into and then in turn
closes
the second form only to select the "refresh" button on the first form to
update a combo box list.

1. How do I code the command button on the first form to go directly to
the
related record on the second form when searching for a record?

2. How do I set some sort of update/refresh on the first form when I
update
and close the second form?

Please let me know if more information is needed? Thanks!

1. Use the WhereCondition parameter of the OpenForm call. If, for example,
your second form is bound to a table or query with a field named ID, you
could open the form positioned to a specific record like this:

DoCmd.OpenForm "form name",,,"[ID] = " & id_value

2. Use the acDialog option in your OpenForm call, then right after the
OpenForm call, do your refresh:

Me.cboBox.Requery


Carl Rapson
 
C

Carl Rapson

The 6th parameter of the OpenForm call lets you specify that the form be
opened as a "dialog", which received exclusive focus until the user
responds. You original form stops processing until the second form (opened
in dialog mode) closes. At that point, you can have the combo box Requery
itself, and any changes made to the data underlying the combo box will show
up:

DoCmd.OpenForm "", , , "[ID] = " & id_value, , acDialog
Me.cboBox.Requery


Carl Rapson

Mike said:
Hey Carl, thanks for responding. I got number 1 ok but I'm a little
uncertain on how to complete number 2. Could you be a little more
specific
or maybe just more in lame terms?

Mike

Carl Rapson said:
Mike said:
Good day Access Gurus! I have a form in which contains a command
button
that
opens another form in which the user inputs data into and then in turn
closes
the second form only to select the "refresh" button on the first form
to
update a combo box list.

1. How do I code the command button on the first form to go directly
to
the
related record on the second form when searching for a record?

2. How do I set some sort of update/refresh on the first form when I
update
and close the second form?

Please let me know if more information is needed? Thanks!

1. Use the WhereCondition parameter of the OpenForm call. If, for
example,
your second form is bound to a table or query with a field named ID, you
could open the form positioned to a specific record like this:

DoCmd.OpenForm "form name",,,"[ID] = " & id_value

2. Use the acDialog option in your OpenForm call, then right after the
OpenForm call, do your refresh:

Me.cboBox.Requery


Carl Rapson
 

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