OpenArgs Dilemma

  • Thread starter Thread starter JamesJ
  • Start date Start date
J

JamesJ

Hi. Me again.
I'm attempting to open a form (frmRemindersEdit) to a specific record using
the
On Dbl Click of a listbox on two separate forms.(/lstWeeklyAppts and
frmReminders/lstReminders)
Each form and each listbox

This is the code I'm using on the On Dbl Click of
the listboxes:

Private Sub lstReminders_DblClick(Cancel As Integer)

DoCmd.OpenForm "frmRemindersEdit", OpenArgs:=Me!ReminderID

End Sub

Code On Open of frmRemindersEdit:

Private Sub Form_Open(Cancel As Integer)

Dim rs As DAO.Recordset

If Not IsNull(Me.OpenArgs) Then
Set rs = Me.RecordsetClone
rs.FindFirst "[ReminderID]=" & Me.OpenArgs
If rs.NoMatch Then

Else

Me.Bookmark = rs.Bookmark

End If
End If

Me!Reminder.SetFocus
Me!Reminder.SelStart = 0

End Sub

When I dblclick on frmReminders/lstReminders frmRemindersEdit
opens to the matching ReminderID but when I dblclick
frmHome/lstWeeklyAppts frmRemindersEdit Opens to the first
record in the recordset. Its appears to be ignoring the ID field.
Any reason why lstWeeklyAppts dbleclick isn't working?

All 3 forms have the ID field included in their RecordSource
and all listboxes have the ID field included in their RowSource.

Thanks,
James
 
Sorry 'bout the repost but.
Actually neither listibox's dbclick works as I want.
Both bring up the first record in frmRemindersEdit's recordset.

James
 
you don't need openargs for this. simply supply the criteria in the where
clause of docmd.openform to open to the specific record

DoCmd.OpenForm "frmRemindersEdit", , , "[ReminderID]=" & Me.ReminderID

Brian

JamesJ said:
Sorry 'bout the repost but.
Actually neither listibox's dbclick works as I want.
Both bring up the first record in frmRemindersEdit's recordset.

James

JamesJ said:
Hi. Me again.
I'm attempting to open a form (frmRemindersEdit) to a specific record
using the
On Dbl Click of a listbox on two separate forms.(/lstWeeklyAppts and
frmReminders/lstReminders)
Each form and each listbox

This is the code I'm using on the On Dbl Click of
the listboxes:

Private Sub lstReminders_DblClick(Cancel As Integer)

DoCmd.OpenForm "frmRemindersEdit", OpenArgs:=Me!ReminderID

End Sub

Code On Open of frmRemindersEdit:

Private Sub Form_Open(Cancel As Integer)

Dim rs As DAO.Recordset

If Not IsNull(Me.OpenArgs) Then
Set rs = Me.RecordsetClone
rs.FindFirst "[ReminderID]=" & Me.OpenArgs
If rs.NoMatch Then

Else

Me.Bookmark = rs.Bookmark

End If
End If

Me!Reminder.SetFocus
Me!Reminder.SelStart = 0

End Sub

When I dblclick on frmReminders/lstReminders frmRemindersEdit
opens to the matching ReminderID but when I dblclick
frmHome/lstWeeklyAppts frmRemindersEdit Opens to the first
record in the recordset. Its appears to be ignoring the ID field.
Any reason why lstWeeklyAppts dbleclick isn't working?

All 3 forms have the ID field included in their RecordSource
and all listboxes have the ID field included in their RowSource.

Thanks,
James
 
Brian Bastl said:
you don't need openargs for this. simply supply the criteria in the where
clause of docmd.openform to open to the specific record

DoCmd.OpenForm "frmRemindersEdit", , , "[ReminderID]=" & Me.ReminderID

Brian

JamesJ said:
Sorry 'bout the repost but.
Actually neither listibox's dbclick works as I want.
Both bring up the first record in frmRemindersEdit's recordset.

James

JamesJ said:
Hi. Me again.
I'm attempting to open a form (frmRemindersEdit) to a specific record
using the
On Dbl Click of a listbox on two separate forms.(/lstWeeklyAppts and
frmReminders/lstReminders)
Each form and each listbox

This is the code I'm using on the On Dbl Click of
the listboxes:

Private Sub lstReminders_DblClick(Cancel As Integer)

DoCmd.OpenForm "frmRemindersEdit", OpenArgs:=Me!ReminderID

End Sub

Code On Open of frmRemindersEdit:

Private Sub Form_Open(Cancel As Integer)

Dim rs As DAO.Recordset

If Not IsNull(Me.OpenArgs) Then
Set rs = Me.RecordsetClone
rs.FindFirst "[ReminderID]=" & Me.OpenArgs
If rs.NoMatch Then

Else

Me.Bookmark = rs.Bookmark

End If
End If

Me!Reminder.SetFocus
Me!Reminder.SelStart = 0

End Sub

When I dblclick on frmReminders/lstReminders frmRemindersEdit
opens to the matching ReminderID but when I dblclick
frmHome/lstWeeklyAppts frmRemindersEdit Opens to the first
record in the recordset. Its appears to be ignoring the ID field.
Any reason why lstWeeklyAppts dbleclick isn't working?

All 3 forms have the ID field included in their RecordSource
and all listboxes have the ID field included in their RowSource.

Thanks,
James
 
Actually, it should be
DoCmd.OpenForm "frmRemindersEdit", , , "[ReminderID]=" & Me.lstReminder

Sorry,
Brian

JamesJ said:
Brian Bastl said:
you don't need openargs for this. simply supply the criteria in the where
clause of docmd.openform to open to the specific record

DoCmd.OpenForm "frmRemindersEdit", , , "[ReminderID]=" & Me.ReminderID

Brian

JamesJ said:
Sorry 'bout the repost but.
Actually neither listibox's dbclick works as I want.
Both bring up the first record in frmRemindersEdit's recordset.

James

Hi. Me again.
I'm attempting to open a form (frmRemindersEdit) to a specific record
using the
On Dbl Click of a listbox on two separate forms.(/lstWeeklyAppts and
frmReminders/lstReminders)
Each form and each listbox

This is the code I'm using on the On Dbl Click of
the listboxes:

Private Sub lstReminders_DblClick(Cancel As Integer)

DoCmd.OpenForm "frmRemindersEdit", OpenArgs:=Me!ReminderID

End Sub

Code On Open of frmRemindersEdit:

Private Sub Form_Open(Cancel As Integer)

Dim rs As DAO.Recordset

If Not IsNull(Me.OpenArgs) Then
Set rs = Me.RecordsetClone
rs.FindFirst "[ReminderID]=" & Me.OpenArgs
If rs.NoMatch Then

Else

Me.Bookmark = rs.Bookmark

End If
End If

Me!Reminder.SetFocus
Me!Reminder.SelStart = 0

End Sub

When I dblclick on frmReminders/lstReminders frmRemindersEdit
opens to the matching ReminderID but when I dblclick
frmHome/lstWeeklyAppts frmRemindersEdit Opens to the first
record in the recordset. Its appears to be ignoring the ID field.
Any reason why lstWeeklyAppts dbleclick isn't working?

All 3 forms have the ID field included in their RecordSource
and all listboxes have the ID field included in their RowSource.

Thanks,
James
 
Actually both works now. I had pasted the incorrect select statement
to frmRemindersEdit and it was only finding a few records so it wasn't
working on certain record types.
Thanks.
I thought it should be simpler. Don't ask where I got the idea for
openargs to do the task.

Thanks again,
James


Brian Bastl said:
Actually, it should be
DoCmd.OpenForm "frmRemindersEdit", , , "[ReminderID]=" & Me.lstReminder

Sorry,
Brian

JamesJ said:
Brian Bastl said:
you don't need openargs for this. simply supply the criteria in the where
clause of docmd.openform to open to the specific record

DoCmd.OpenForm "frmRemindersEdit", , , "[ReminderID]=" & Me.ReminderID

Brian

Sorry 'bout the repost but.
Actually neither listibox's dbclick works as I want.
Both bring up the first record in frmRemindersEdit's recordset.

James

Hi. Me again.
I'm attempting to open a form (frmRemindersEdit) to a specific
record
using the
On Dbl Click of a listbox on two separate forms.(/lstWeeklyAppts and
frmReminders/lstReminders)
Each form and each listbox

This is the code I'm using on the On Dbl Click of
the listboxes:

Private Sub lstReminders_DblClick(Cancel As Integer)

DoCmd.OpenForm "frmRemindersEdit", OpenArgs:=Me!ReminderID

End Sub

Code On Open of frmRemindersEdit:

Private Sub Form_Open(Cancel As Integer)

Dim rs As DAO.Recordset

If Not IsNull(Me.OpenArgs) Then
Set rs = Me.RecordsetClone
rs.FindFirst "[ReminderID]=" & Me.OpenArgs
If rs.NoMatch Then

Else

Me.Bookmark = rs.Bookmark

End If
End If

Me!Reminder.SetFocus
Me!Reminder.SelStart = 0

End Sub

When I dblclick on frmReminders/lstReminders frmRemindersEdit
opens to the matching ReminderID but when I dblclick
frmHome/lstWeeklyAppts frmRemindersEdit Opens to the first
record in the recordset. Its appears to be ignoring the ID field.
Any reason why lstWeeklyAppts dbleclick isn't working?

All 3 forms have the ID field included in their RecordSource
and all listboxes have the ID field included in their RowSource.

Thanks,
James
 
JamesJ said:
Sorry 'bout the repost but.
Actually neither listibox's dbclick works as I want.
Both bring up the first record in frmRemindersEdit's recordset.

James

Hi. Me again.
I'm attempting to open a form (frmRemindersEdit) to a specific record
using the
On Dbl Click of a listbox on two separate forms.(/lstWeeklyAppts and
frmReminders/lstReminders)
Each form and each listbox

This is the code I'm using on the On Dbl Click of
the listboxes:

Private Sub lstReminders_DblClick(Cancel As Integer)

DoCmd.OpenForm "frmRemindersEdit", OpenArgs:=Me!ReminderID

End Sub

Code On Open of frmRemindersEdit:

Private Sub Form_Open(Cancel As Integer)

Dim rs As DAO.Recordset

If Not IsNull(Me.OpenArgs) Then
Set rs = Me.RecordsetClone
rs.FindFirst "[ReminderID]=" & Me.OpenArgs
If rs.NoMatch Then

Else

Me.Bookmark = rs.Bookmark

End If
End If

Me!Reminder.SetFocus
Me!Reminder.SelStart = 0

End Sub

When I dblclick on frmReminders/lstReminders frmRemindersEdit
opens to the matching ReminderID but when I dblclick
frmHome/lstWeeklyAppts frmRemindersEdit Opens to the first
record in the recordset. Its appears to be ignoring the ID field.
Any reason why lstWeeklyAppts dbleclick isn't working?

All 3 forms have the ID field included in their RecordSource
and all listboxes have the ID field included in their RowSource.

Thanks,
James

You should be using the name of the list box (which has the bound column
[ReminderID]), not the name of a field.


should be (if the list box is "List0":

DoCmd.OpenForm "frmRemindersEdit", OpenArgs:=Me!List0


HTH
 
Back
Top