Opening form to specific record\

B

BRC

Hi all

I am trying to open a form to a specific record based on dbl clicking
a record on the sub form of another form. Here is the situation.
Form1 (SelReceditFrm ) is open with a date field where user enters
date
after user selects date all "events" for that date show up in subform.
When user dblclicks on an event listed in the subform I want the event
form("eventtfrm" to upen to that record in the edit mode.
when the user dbl clicks on the event I set a message box to display
the "eventKey" which is the event i want to edit.
this is the code
Private Sub event_DblClick(Cancel As Integer)
dim evk as interger
'evnetkey is an auto number field
evk = Me.EventKey
MsgBox (evk)
'DoCmd.OpenForm "eventFrm", , "[eventkey]='" & evk& "' "
'DoCmd.OpenForm "eventFrm", acNormal, , EventKey = evk, acFormEdit
'DoCmd.OpenForm "eventFrm", acNormal, filt, EventKey = filt,
acFormedit,,,)
End Sub
my problem may have something to do with punctuation but I can't find
a good explanation of how to punctuate.
 
K

Ken Snell \(MVP\)

The fourth argument is the one you use to send the filtering string to the
form that is being opened. In your code, you have your string as the third
argument. Try this:

DoCmd.OpenForm "eventFrm", , , "[eventkey]='" & evk& "'"
 
B

BRC

The fourth argument is the one you use to send the filtering string to the
form that is being opened. In your code, you have your string as the third
argument. Try this:

DoCmd.OpenForm "eventFrm", , , "[eventkey]='" & evk& "'"

--

Ken Snell
<MS ACCESS MVP>




I am trying to open a form to a specific record based on dbl clicking
a record on the sub form of another form. Here is the situation.
Form1 (SelReceditFrm ) is open with a date field where user enters
date
after user selects date all "events" for that date show up in subform.
When user dblclicks on an event listed in the subform I want the event
form("eventtfrm" to upen to that record in the edit mode.
when the user dbl clicks on the event I set a message box to display
the "eventKey" which is the event i want to edit.
this is the code
Private Sub event_DblClick(Cancel As Integer)
dim evk as interger
'evnetkey is an auto number field
evk = Me.EventKey
MsgBox (evk)
'DoCmd.OpenForm "eventFrm", , "[eventkey]='" & evk& "' "
'DoCmd.OpenForm "eventFrm", acNormal, , EventKey = evk, acFormEdit
'DoCmd.OpenForm "eventFrm", acNormal, filt, EventKey = filt,
acFormedit,,,)
End Sub
my problem may have something to do with punctuation but I can't find
a good explanation of how to punctuate.- Hide quoted text -

- Show quoted text -

Ken,
Thank you.
I did have the argument in the wrong position. Here is the code that
actually works the way I wanted:
***************************
Private Sub event_DblClick(Cancel As Integer)
Dim evk As String 'Integer
evk = Me.EventKey
MsgBox (evk)
DoCmd.OpenForm "eventFrm", , , "[eventkey]=" & evk, acFormEdit
End Sub
*******************************
It didn't seem to matter if i dim'd evk as string or integer. I think
my problem is i don't really understand the syntax and punctuation of
these statements. i.e. when to use quotes, brakets etc. If you know of
any good references for this type of thing I would appreicate the
advise. Thanks again
BRC
 
K

Ken Snell \(MVP\)

If a field is a number field, you do not use any delimiter.

If a field is a text or memo field, you use a ' delimiter.

If a field is a date/time field, you use a # delimiter if you're passing a
"mm/dd/yyyy" , "hh:nn:ss" , or "mm/dd/yyyy hh:nn:ss" type of date/time.
Remember that Jet will assume US format of date if you provide it with an
ambigous date (e.g., 03/05/2007 -- which is March 5, 2007 in US, and May 3,
2007 in Europe and elsewhere).

--

Ken Snell
<MS ACCESS MVP>


BRC said:
The fourth argument is the one you use to send the filtering string to
the
form that is being opened. In your code, you have your string as the
third
argument. Try this:

DoCmd.OpenForm "eventFrm", , , "[eventkey]='" & evk& "'"

--

Ken Snell
<MS ACCESS MVP>




I am trying to open a form to a specific record based on dbl clicking
a record on the sub form of another form. Here is the situation.
Form1 (SelReceditFrm ) is open with a date field where user enters
date
after user selects date all "events" for that date show up in subform.
When user dblclicks on an event listed in the subform I want the event
form("eventtfrm" to upen to that record in the edit mode.
when the user dbl clicks on the event I set a message box to display
the "eventKey" which is the event i want to edit.
this is the code
Private Sub event_DblClick(Cancel As Integer)
dim evk as interger
'evnetkey is an auto number field
evk = Me.EventKey
MsgBox (evk)
'DoCmd.OpenForm "eventFrm", , "[eventkey]='" & evk& "' "
'DoCmd.OpenForm "eventFrm", acNormal, , EventKey = evk, acFormEdit
'DoCmd.OpenForm "eventFrm", acNormal, filt, EventKey = filt,
acFormedit,,,)
End Sub
my problem may have something to do with punctuation but I can't find
a good explanation of how to punctuate.- Hide quoted text -

- Show quoted text -

Ken,
Thank you.
I did have the argument in the wrong position. Here is the code that
actually works the way I wanted:
***************************
Private Sub event_DblClick(Cancel As Integer)
Dim evk As String 'Integer
evk = Me.EventKey
MsgBox (evk)
DoCmd.OpenForm "eventFrm", , , "[eventkey]=" & evk, acFormEdit
End Sub
*******************************
It didn't seem to matter if i dim'd evk as string or integer. I think
my problem is i don't really understand the syntax and punctuation of
these statements. i.e. when to use quotes, brakets etc. If you know of
any good references for this type of thing I would appreicate the
advise. Thanks again
BRC
 

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