Re: Enter key behavior
From: Jan (ongshat2003_at_yahoo.com)
Date: 02/12/04
- Next message: Dirk Goldgar: "Re: Setting Subform Recordsource in a tabbed form"
- Previous message: Alejandro: "Re: parameter in combobox"
- In reply to: Allen Browne: "Re: Enter key behavior"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 12 Feb 2004 16:45:46 -0500
Hi Allen,
Thanks for the reply. As to your first comment re error 2174, that is the
message I get when I try and switch to form view. What I don't understand
is why I can do it by double clicking on the field property (the first field
in the row) but not with a key down event. This doesn't make sense to me.
As to your last alternative, a similar idea was originally my first and
favorite choice. However, I abandoned it when I couldn't get it to work
correctly. A dialog form opens and the user types in part or all of a
customer name. Then a filtered form (in continuous form view) opens
displaying a small set of records with a few fields. User then selects a
record and opens a form in form view with all fields displayed. The user
must be able to move back and forth through the recordset in form view.
There is a button on this form to go back to the filtered continuous form so
he
can select another record. The code I've included below works great until
the user goes back to the filtered form, then moves back to the form view
form after selecting a new record to view. The record displayed is still
the first record. In other words the bookmark in the single form did not
update to reflect the bookmark in the filtered continuous form.
Below I've included the code from my forms in the hope you could help me.
(I hope so.) I know this posting is long and I apologize, but I am pretty
desperate.
Jan
Code in dialog form to generate filter: (In a button to open the filtered
form that will display only those records "Like" the criteria.
Private Sub cmdOK_Click()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmGetCustomersFilter"
stLinkCriteria = "[CustomerName]like " & "'" & Me![SelectName] & "' &
'*'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Me!SelectName = Null
Me.Visible = False
End Sub
Code in FilterForm: Form that displays on 3 or 4 fields in continuous form
view.
Private Sub cmdOpenCustomers_Click()
On Error GoTo Err_cmdOpenCustomers_Click
Dim db As Database
Dim rst As Recordset
Dim varBookmark As Variant
Dim stDocName As String
Set rst = Me.RecordsetClone
varBookmark = rst.Bookmark
stDocName = "frmCustomers"
DoCmd.OpenForm "frmCustomers", , , , , , CustomerID
rst.FindFirst [CustomerID] = " & Me.CustomerID"
rst.Bookmark = varBookmark
Exit_cmdOpenCustomers_Click:
Exit Sub
Err_cmdOpenCustomers_Click:
MsgBox Err.Description
Resume Exit_cmdOpenCustomers_Click
End Sub
Code in Load property of main form (displayed in form view)
Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
Dim rst As DAO.Recordset
Set rst = Me.RecordsetClone
rst.FindFirst "CustormerID = " & Me.OpenArgs
If Not rst.NoMatch Then
Me.Bookmark = rst.Bookmark
End If
End If
rst.Close
End Sub
"Allen Browne" <AllenBrowne@SeeSig.Invalid> wrote in message
news:402af28a$0$1742$5a62ac22@freenews.iinet.net.au...
> HI Jan
>
> Can remember fiddling with this briefly, and getting stuck with error
2174 -
> "You can't switch views at this time." The message suggests that a change
of
> view cannot occur in the KeyDown event of a control, because there are so
> many other events that must be processed first, e.g. KeyUp, KeyPress,
> Change, control's BeforeUpdate, control's AfterUpdate, possibly Exit and
> LostFocus, and if the form is dirty then the form's BeforeUpdate and
> AfterUpdate as well.
>
> It may be possible to set a module-level flag, and then test it and switch
> views in the form's Timer event, but that seems horribly inefficient and
> problematic also.
>
> A simple alternative might be to add a navigation pane, so the user can
> select a record from the list on the left, and view the record (form view)
> on the right. This is just a matter of creating another unbound form, with
a
> list box on the left, and then put your existing form on the right as a
> subform. Set the subform control's LinkMasterFields property to the name
of
> the listbox, and the matching subform field name in its LinkChildFields
> property.
>
> --
> Allen Browne - Microsoft MVP. Perth, Western Australia.
> Tips for Access users - http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "Jan" <ongshat2003@yahoo.com> wrote in message
> news:%23uLUF3Q8DHA.3008@TK2MSFTNGP09.phx.gbl...
> >
> > Is it possible to reprogram the ENTER key to switch to form view from
> > datasheet view by pressing ENTER in a specific field.
> >
> > I need to have a user open a filtered form in datasheet view showing
only
> 2
> > fields, then using the arrow key to move down to select a record, switch
> to
> > form view by pressing ENTER. I can do it by putting a button on a
> floating
> > toolbar and I've allowed them to switch by double-clicking on the field
> but
> > the client insists on providing the ENTER key procedure. I've spent
days
> on
> > this
> > because this is what the client wants and I can't get it to work.
> >
> > Thanks for any help.
> > Jan
>
>
- Next message: Dirk Goldgar: "Re: Setting Subform Recordsource in a tabbed form"
- Previous message: Alejandro: "Re: parameter in combobox"
- In reply to: Allen Browne: "Re: Enter key behavior"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|