User Record search

G

Guest

Can anyone help me? I want my users to be able to search for a record in a
table and generate the data of that record on an edit view. I am used to
having a GRID (Table view), double clicking on the record I need and the
double click open an edit view form with the data for that record populated.

I am basing my edit view off of a 3 Table query. Two of the tables relate
to the 3rd using foreign keys. I have tried opening a subform on a tab to
get the grid and trying programatically to populate the edit view from that
grid.

Any help would be appreciated.
 
A

Allen Browne

Create a form, bound to your 3-table query.
Set its Default Value to Datasheet if you wish (or Continuous.)
You can now use the DblClick event of any control you like to open the other
form.

The code for the event procedure would be something like this:
Dim strWhere As String
If Me.Dirty Then
Me.Dirty = False 'Save first.
End If
If Me.NewRecord Then
Beep
Else
strWhere = "MyOtherField = " & Me.[MyIdField]
DoCmd.OpenForm "Form2", WhereCondition = strWhere
End If

Note that that won't work of Form2 is already open.
 
G

Guest

There doesn't seem to be a DBLClick event on the subform object and the
record in focus is not defined, just the subform object.

Can you comment on this?
--
Patrick G. Loop


Allen Browne said:
Create a form, bound to your 3-table query.
Set its Default Value to Datasheet if you wish (or Continuous.)
You can now use the DblClick event of any control you like to open the other
form.

The code for the event procedure would be something like this:
Dim strWhere As String
If Me.Dirty Then
Me.Dirty = False 'Save first.
End If
If Me.NewRecord Then
Beep
Else
strWhere = "MyOtherField = " & Me.[MyIdField]
DoCmd.OpenForm "Form2", WhereCondition = strWhere
End If

Note that that won't work of Form2 is already open.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

PGLoop said:
Can anyone help me? I want my users to be able to search for a record in a
table and generate the data of that record on an edit view. I am used to
having a GRID (Table view), double clicking on the record I need and the
double click open an edit view form with the data for that record
populated.

I am basing my edit view off of a 3 Table query. Two of the tables relate
to the 3rd using foreign keys. I have tried opening a subform on a tab
to
get the grid and trying programatically to populate the edit view from
that
grid.

Any help would be appreciated.
 
A

Allen Browne

If the subform is in Continuous view, you can add a command button to the
Detail section, so it shows up on each row.

Alternatively, you can use the DblClick event of a suitable control in the
subform (or of all controls if you want to do that.)

If is is a bound form, it does have a current record. If you are not clear
which one this is, make sure the subform's Record Selector property is set
to Yes.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

PGLoop said:
There doesn't seem to be a DBLClick event on the subform object and the
record in focus is not defined, just the subform object.

Can you comment on this?
--
Patrick G. Loop


Allen Browne said:
Create a form, bound to your 3-table query.
Set its Default Value to Datasheet if you wish (or Continuous.)
You can now use the DblClick event of any control you like to open the
other
form.

The code for the event procedure would be something like this:
Dim strWhere As String
If Me.Dirty Then
Me.Dirty = False 'Save first.
End If
If Me.NewRecord Then
Beep
Else
strWhere = "MyOtherField = " & Me.[MyIdField]
DoCmd.OpenForm "Form2", WhereCondition = strWhere
End If

Note that that won't work of Form2 is already open.

PGLoop said:
Can anyone help me? I want my users to be able to search for a record
in a
table and generate the data of that record on an edit view. I am used
to
having a GRID (Table view), double clicking on the record I need and
the
double click open an edit view form with the data for that record
populated.

I am basing my edit view off of a 3 Table query. Two of the tables
relate
to the 3rd using foreign keys. I have tried opening a subform on a
tab
to
get the grid and trying programatically to populate the edit view from
that
grid.

Any help would be appreciated.
 
G

Guest

Thanks very much, you have truly shone the light on the issue!
--
Patrick G. Loop


Allen Browne said:
If the subform is in Continuous view, you can add a command button to the
Detail section, so it shows up on each row.

Alternatively, you can use the DblClick event of a suitable control in the
subform (or of all controls if you want to do that.)

If is is a bound form, it does have a current record. If you are not clear
which one this is, make sure the subform's Record Selector property is set
to Yes.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

PGLoop said:
There doesn't seem to be a DBLClick event on the subform object and the
record in focus is not defined, just the subform object.

Can you comment on this?
--
Patrick G. Loop


Allen Browne said:
Create a form, bound to your 3-table query.
Set its Default Value to Datasheet if you wish (or Continuous.)
You can now use the DblClick event of any control you like to open the
other
form.

The code for the event procedure would be something like this:
Dim strWhere As String
If Me.Dirty Then
Me.Dirty = False 'Save first.
End If
If Me.NewRecord Then
Beep
Else
strWhere = "MyOtherField = " & Me.[MyIdField]
DoCmd.OpenForm "Form2", WhereCondition = strWhere
End If

Note that that won't work of Form2 is already open.

Can anyone help me? I want my users to be able to search for a record
in a
table and generate the data of that record on an edit view. I am used
to
having a GRID (Table view), double clicking on the record I need and
the
double click open an edit view form with the data for that record
populated.

I am basing my edit view off of a 3 Table query. Two of the tables
relate
to the 3rd using foreign keys. I have tried opening a subform on a
tab
to
get the grid and trying programatically to populate the edit view from
that
grid.

Any help would be appreciated.
 

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