PC Review


Reply
Thread Tools Rate Thread

Bookmark issues

 
 
=?Utf-8?B?U2VyZW4=?=
Guest
Posts: n/a
 
      26th Apr 2006
I have a form with a subform in it. When a tool number is entered in the
subform, if it already exists in the table, I want that record to be returned
to the subform to populate the remaining fields in that subform. I am having
a problem with my code... I get an error on the Me.Bookmark = rsc.Bookmark
line. The tooltip says Me.Bookmark = <No Current Record.>

Anyone have any suggestions for me?

Thanks a bunch!
Seren

Private Sub ToolNum_BeforeUpdate(Cancel As Integer)
Dim TNum As String
Dim stDup As String
Dim rsc As dao.Recordset

Set rsc = Form_subTool.RecordsetClone

TNum = Form_subTool.ToolNum.Value
stDup = "ToolNum = " & "'" & TNum & "'"

' check if toolnum already exists in tblTool
If DCount("ToolNum", "tblTool", stDup) > 0 Then
' clear toolNum field
Me.Undo
' set form to existing matching record
rsc.FindFirst stDup
Me.Bookmark = rsc.Bookmark
End If
Set rsc = Nothing
End Sub


 
Reply With Quote
 
 
 
 
=?Utf-8?B?S2xhdHV1?=
Guest
Posts: n/a
 
      26th Apr 2006
You should always check to see if you found a match before you move a bookmark.

rsc.FindFirst stDup
If Not rsc.NoMatch Then
Me.Bookmark = rsc.Bookmark
Else
'Whatever you want to do if a match was not found
End If

"Seren" wrote:

> I have a form with a subform in it. When a tool number is entered in the
> subform, if it already exists in the table, I want that record to be returned
> to the subform to populate the remaining fields in that subform. I am having
> a problem with my code... I get an error on the Me.Bookmark = rsc.Bookmark
> line. The tooltip says Me.Bookmark = <No Current Record.>
>
> Anyone have any suggestions for me?
>
> Thanks a bunch!
> Seren
>
> Private Sub ToolNum_BeforeUpdate(Cancel As Integer)
> Dim TNum As String
> Dim stDup As String
> Dim rsc As dao.Recordset
>
> Set rsc = Form_subTool.RecordsetClone
>
> TNum = Form_subTool.ToolNum.Value
> stDup = "ToolNum = " & "'" & TNum & "'"
>
> ' check if toolnum already exists in tblTool
> If DCount("ToolNum", "tblTool", stDup) > 0 Then
> ' clear toolNum field
> Me.Undo
> ' set form to existing matching record
> rsc.FindFirst stDup
> Me.Bookmark = rsc.Bookmark
> End If
> Set rsc = Nothing
> End Sub
>
>

 
Reply With Quote
 
=?Utf-8?B?U2VyZW4=?=
Guest
Posts: n/a
 
      26th Apr 2006
But if there is not a match, it shouldn't be called anyway...
--
Always behave like a duck- keep calm and unruffled on the surface but paddle
like the devil underneath.


"Klatuu" wrote:

> You should always check to see if you found a match before you move a bookmark.
>
> rsc.FindFirst stDup
> If Not rsc.NoMatch Then
> Me.Bookmark = rsc.Bookmark
> Else
> 'Whatever you want to do if a match was not found
> End If
>
> "Seren" wrote:
>
> > I have a form with a subform in it. When a tool number is entered in the
> > subform, if it already exists in the table, I want that record to be returned
> > to the subform to populate the remaining fields in that subform. I am having
> > a problem with my code... I get an error on the Me.Bookmark = rsc.Bookmark
> > line. The tooltip says Me.Bookmark = <No Current Record.>
> >
> > Anyone have any suggestions for me?
> >
> > Thanks a bunch!
> > Seren
> >
> > Private Sub ToolNum_BeforeUpdate(Cancel As Integer)
> > Dim TNum As String
> > Dim stDup As String
> > Dim rsc As dao.Recordset
> >
> > Set rsc = Form_subTool.RecordsetClone
> >
> > TNum = Form_subTool.ToolNum.Value
> > stDup = "ToolNum = " & "'" & TNum & "'"
> >
> > ' check if toolnum already exists in tblTool
> > If DCount("ToolNum", "tblTool", stDup) > 0 Then
> > ' clear toolNum field
> > Me.Undo
> > ' set form to existing matching record
> > rsc.FindFirst stDup
> > Me.Bookmark = rsc.Bookmark
> > End If
> > Set rsc = Nothing
> > End Sub
> >
> >

 
Reply With Quote
 
=?Utf-8?B?S2xhdHV1?=
Guest
Posts: n/a
 
      26th Apr 2006
I see your point. One thing I do notice. Is Form_SubTool the sub form? If
so, it should be qualified with the parent form name. I can't debug it from
here, so I can't see what the real problem is; however, the DCount is
redundant and will slow your response. I suggest you try this modification
and see what happens:

Private Sub ToolNum_BeforeUpdate(Cancel As Integer)
Dim rsc As dao.Recordset

Set rsc = Forms!MainFormName!Form_subTool.RecordsetClone

' set form to existing matching record
rsc.FindFirst "[ToolNum] = '" & _
Forms!MainFormName!Form_subTool.ToolNum & "'"
If rsc.NoMatch Then
Cancel = 0
MsgBox "Tool Not Found"
Else
Me.Bookmark = rsc.Bookmark
End If
Set rsc = Nothing
End Sub


"Seren" wrote:

> But if there is not a match, it shouldn't be called anyway...
> --
> Always behave like a duck- keep calm and unruffled on the surface but paddle
> like the devil underneath.
>
>
> "Klatuu" wrote:
>
> > You should always check to see if you found a match before you move a bookmark.
> >
> > rsc.FindFirst stDup
> > If Not rsc.NoMatch Then
> > Me.Bookmark = rsc.Bookmark
> > Else
> > 'Whatever you want to do if a match was not found
> > End If
> >
> > "Seren" wrote:
> >
> > > I have a form with a subform in it. When a tool number is entered in the
> > > subform, if it already exists in the table, I want that record to be returned
> > > to the subform to populate the remaining fields in that subform. I am having
> > > a problem with my code... I get an error on the Me.Bookmark = rsc.Bookmark
> > > line. The tooltip says Me.Bookmark = <No Current Record.>
> > >
> > > Anyone have any suggestions for me?
> > >
> > > Thanks a bunch!
> > > Seren
> > >
> > > Private Sub ToolNum_BeforeUpdate(Cancel As Integer)
> > > Dim TNum As String
> > > Dim stDup As String
> > > Dim rsc As dao.Recordset
> > >
> > > Set rsc = Form_subTool.RecordsetClone
> > >
> > > TNum = Form_subTool.ToolNum.Value
> > > stDup = "ToolNum = " & "'" & TNum & "'"
> > >
> > > ' check if toolnum already exists in tblTool
> > > If DCount("ToolNum", "tblTool", stDup) > 0 Then
> > > ' clear toolNum field
> > > Me.Undo
> > > ' set form to existing matching record
> > > rsc.FindFirst stDup
> > > Me.Bookmark = rsc.Bookmark
> > > End If
> > > Set rsc = Nothing
> > > End Sub
> > >
> > >

 
Reply With Quote
 
=?Utf-8?B?U2VyZW4=?=
Guest
Posts: n/a
 
      26th Apr 2006
With that, it switches the error from the "me.bookmark" line to the " set rsc
= " and tooltip says "rsc = Nothing"
--
Always behave like a duck- keep calm and unruffled on the surface but paddle
like the devil underneath.


"Klatuu" wrote:

> I see your point. One thing I do notice. Is Form_SubTool the sub form? If
> so, it should be qualified with the parent form name. I can't debug it from
> here, so I can't see what the real problem is; however, the DCount is
> redundant and will slow your response. I suggest you try this modification
> and see what happens:
>
> Private Sub ToolNum_BeforeUpdate(Cancel As Integer)
> Dim rsc As dao.Recordset
>
> Set rsc = Forms!MainFormName!Form_subTool.RecordsetClone
>
> ' set form to existing matching record
> rsc.FindFirst "[ToolNum] = '" & _
> Forms!MainFormName!Form_subTool.ToolNum & "'"
> If rsc.NoMatch Then
> Cancel = 0
> MsgBox "Tool Not Found"
> Else
> Me.Bookmark = rsc.Bookmark
> End If
> Set rsc = Nothing
> End Sub
>
>
> "Seren" wrote:
>
> > But if there is not a match, it shouldn't be called anyway...
> > --
> > Always behave like a duck- keep calm and unruffled on the surface but paddle
> > like the devil underneath.
> >
> >
> > "Klatuu" wrote:
> >
> > > You should always check to see if you found a match before you move a bookmark.
> > >
> > > rsc.FindFirst stDup
> > > If Not rsc.NoMatch Then
> > > Me.Bookmark = rsc.Bookmark
> > > Else
> > > 'Whatever you want to do if a match was not found
> > > End If
> > >
> > > "Seren" wrote:
> > >
> > > > I have a form with a subform in it. When a tool number is entered in the
> > > > subform, if it already exists in the table, I want that record to be returned
> > > > to the subform to populate the remaining fields in that subform. I am having
> > > > a problem with my code... I get an error on the Me.Bookmark = rsc.Bookmark
> > > > line. The tooltip says Me.Bookmark = <No Current Record.>
> > > >
> > > > Anyone have any suggestions for me?
> > > >
> > > > Thanks a bunch!
> > > > Seren
> > > >
> > > > Private Sub ToolNum_BeforeUpdate(Cancel As Integer)
> > > > Dim TNum As String
> > > > Dim stDup As String
> > > > Dim rsc As dao.Recordset
> > > >
> > > > Set rsc = Form_subTool.RecordsetClone
> > > >
> > > > TNum = Form_subTool.ToolNum.Value
> > > > stDup = "ToolNum = " & "'" & TNum & "'"
> > > >
> > > > ' check if toolnum already exists in tblTool
> > > > If DCount("ToolNum", "tblTool", stDup) > 0 Then
> > > > ' clear toolNum field
> > > > Me.Undo
> > > > ' set form to existing matching record
> > > > rsc.FindFirst stDup
> > > > Me.Bookmark = rsc.Bookmark
> > > > End If
> > > > Set rsc = Nothing
> > > > End Sub
> > > >
> > > >

 
Reply With Quote
 
=?Utf-8?B?S2xhdHV1?=
Guest
Posts: n/a
 
      26th Apr 2006
Are you trying to set it to the current form's recordsetclone. You are not
clear on which form you are working. If it is the current form, all you need
is Me.RecordsetClone.

"Seren" wrote:

> With that, it switches the error from the "me.bookmark" line to the " set rsc
> = " and tooltip says "rsc = Nothing"
> --
> Always behave like a duck- keep calm and unruffled on the surface but paddle
> like the devil underneath.
>
>
> "Klatuu" wrote:
>
> > I see your point. One thing I do notice. Is Form_SubTool the sub form? If
> > so, it should be qualified with the parent form name. I can't debug it from
> > here, so I can't see what the real problem is; however, the DCount is
> > redundant and will slow your response. I suggest you try this modification
> > and see what happens:
> >
> > Private Sub ToolNum_BeforeUpdate(Cancel As Integer)
> > Dim rsc As dao.Recordset
> >
> > Set rsc = Forms!MainFormName!Form_subTool.RecordsetClone
> >
> > ' set form to existing matching record
> > rsc.FindFirst "[ToolNum] = '" & _
> > Forms!MainFormName!Form_subTool.ToolNum & "'"
> > If rsc.NoMatch Then
> > Cancel = 0
> > MsgBox "Tool Not Found"
> > Else
> > Me.Bookmark = rsc.Bookmark
> > End If
> > Set rsc = Nothing
> > End Sub
> >
> >
> > "Seren" wrote:
> >
> > > But if there is not a match, it shouldn't be called anyway...
> > > --
> > > Always behave like a duck- keep calm and unruffled on the surface but paddle
> > > like the devil underneath.
> > >
> > >
> > > "Klatuu" wrote:
> > >
> > > > You should always check to see if you found a match before you move a bookmark.
> > > >
> > > > rsc.FindFirst stDup
> > > > If Not rsc.NoMatch Then
> > > > Me.Bookmark = rsc.Bookmark
> > > > Else
> > > > 'Whatever you want to do if a match was not found
> > > > End If
> > > >
> > > > "Seren" wrote:
> > > >
> > > > > I have a form with a subform in it. When a tool number is entered in the
> > > > > subform, if it already exists in the table, I want that record to be returned
> > > > > to the subform to populate the remaining fields in that subform. I am having
> > > > > a problem with my code... I get an error on the Me.Bookmark = rsc.Bookmark
> > > > > line. The tooltip says Me.Bookmark = <No Current Record.>
> > > > >
> > > > > Anyone have any suggestions for me?
> > > > >
> > > > > Thanks a bunch!
> > > > > Seren
> > > > >
> > > > > Private Sub ToolNum_BeforeUpdate(Cancel As Integer)
> > > > > Dim TNum As String
> > > > > Dim stDup As String
> > > > > Dim rsc As dao.Recordset
> > > > >
> > > > > Set rsc = Form_subTool.RecordsetClone
> > > > >
> > > > > TNum = Form_subTool.ToolNum.Value
> > > > > stDup = "ToolNum = " & "'" & TNum & "'"
> > > > >
> > > > > ' check if toolnum already exists in tblTool
> > > > > If DCount("ToolNum", "tblTool", stDup) > 0 Then
> > > > > ' clear toolNum field
> > > > > Me.Undo
> > > > > ' set form to existing matching record
> > > > > rsc.FindFirst stDup
> > > > > Me.Bookmark = rsc.Bookmark
> > > > > End If
> > > > > Set rsc = Nothing
> > > > > End Sub
> > > > >
> > > > >

 
Reply With Quote
 
=?Utf-8?B?U2VyZW4=?=
Guest
Posts: n/a
 
      27th Apr 2006
Actually, that was one question I have. When I'm working with a subform,
should I be setting those properties on the subform itself or the subform
property within the main form? I don't know if that even makes sense. I've
been thinking about it too long it's all starting to run together and not
make sense.

So, after speaking with someone here... i tried switching the form with the
subform. He said something about the way it was looking for multiple tool
numbers for each job number. (Job was main form, tool was subform). So, I
switched it, made tool main form, job subform. So it's now working... only--
backwards.

You can enter a tool number and get the first Job that goes with that...
with navigation buttons to seemingly allow you to flip through each
associated tool for that job. But when you try to go to the next job for
that tool, it all goes blank.

what I need to happen is for the user to type in the Job number and get the
*one* associated tool number. This is slowly but surely driving me crazy. :P
--
Always behave like a duck- keep calm and unruffled on the surface but paddle
like the devil underneath.


"Klatuu" wrote:

> Are you trying to set it to the current form's recordsetclone. You are not
> clear on which form you are working. If it is the current form, all you need
> is Me.RecordsetClone.
>
> "Seren" wrote:
>
> > With that, it switches the error from the "me.bookmark" line to the " set rsc
> > = " and tooltip says "rsc = Nothing"
> > --
> > Always behave like a duck- keep calm and unruffled on the surface but paddle
> > like the devil underneath.
> >
> >
> > "Klatuu" wrote:
> >
> > > I see your point. One thing I do notice. Is Form_SubTool the sub form? If
> > > so, it should be qualified with the parent form name. I can't debug it from
> > > here, so I can't see what the real problem is; however, the DCount is
> > > redundant and will slow your response. I suggest you try this modification
> > > and see what happens:
> > >
> > > Private Sub ToolNum_BeforeUpdate(Cancel As Integer)
> > > Dim rsc As dao.Recordset
> > >
> > > Set rsc = Forms!MainFormName!Form_subTool.RecordsetClone
> > >
> > > ' set form to existing matching record
> > > rsc.FindFirst "[ToolNum] = '" & _
> > > Forms!MainFormName!Form_subTool.ToolNum & "'"
> > > If rsc.NoMatch Then
> > > Cancel = 0
> > > MsgBox "Tool Not Found"
> > > Else
> > > Me.Bookmark = rsc.Bookmark
> > > End If
> > > Set rsc = Nothing
> > > End Sub
> > >
> > >
> > > "Seren" wrote:
> > >
> > > > But if there is not a match, it shouldn't be called anyway...
> > > > --
> > > > Always behave like a duck- keep calm and unruffled on the surface but paddle
> > > > like the devil underneath.
> > > >
> > > >
> > > > "Klatuu" wrote:
> > > >
> > > > > You should always check to see if you found a match before you move a bookmark.
> > > > >
> > > > > rsc.FindFirst stDup
> > > > > If Not rsc.NoMatch Then
> > > > > Me.Bookmark = rsc.Bookmark
> > > > > Else
> > > > > 'Whatever you want to do if a match was not found
> > > > > End If
> > > > >
> > > > > "Seren" wrote:
> > > > >
> > > > > > I have a form with a subform in it. When a tool number is entered in the
> > > > > > subform, if it already exists in the table, I want that record to be returned
> > > > > > to the subform to populate the remaining fields in that subform. I am having
> > > > > > a problem with my code... I get an error on the Me.Bookmark = rsc.Bookmark
> > > > > > line. The tooltip says Me.Bookmark = <No Current Record.>
> > > > > >
> > > > > > Anyone have any suggestions for me?
> > > > > >
> > > > > > Thanks a bunch!
> > > > > > Seren
> > > > > >
> > > > > > Private Sub ToolNum_BeforeUpdate(Cancel As Integer)
> > > > > > Dim TNum As String
> > > > > > Dim stDup As String
> > > > > > Dim rsc As dao.Recordset
> > > > > >
> > > > > > Set rsc = Form_subTool.RecordsetClone
> > > > > >
> > > > > > TNum = Form_subTool.ToolNum.Value
> > > > > > stDup = "ToolNum = " & "'" & TNum & "'"
> > > > > >
> > > > > > ' check if toolnum already exists in tblTool
> > > > > > If DCount("ToolNum", "tblTool", stDup) > 0 Then
> > > > > > ' clear toolNum field
> > > > > > Me.Undo
> > > > > > ' set form to existing matching record
> > > > > > rsc.FindFirst stDup
> > > > > > Me.Bookmark = rsc.Bookmark
> > > > > > End If
> > > > > > Set rsc = Nothing
> > > > > > End Sub
> > > > > >
> > > > > >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
link from outlook to word bookmark opens doc but not at bookmark JOH Microsoft Outlook 1 2nd May 2008 03:58 AM
Bookmark page rather than bookmark site =?Utf-8?B?RG91ZyBTdGV3YXJ0?= Microsoft Frontpage 7 4th Mar 2007 05:00 PM
create a bookmark within a bookmark Barry Karas Windows XP Help 0 12th Oct 2006 06:36 AM
My noteref to valid bookmark says "Error! Bookmark not defined."? =?Utf-8?B?amNoaWxkZXJzXzk4?= Microsoft Word Document Management 3 5th Oct 2006 02:23 PM
Bookmark Issues in MS Word XP =?Utf-8?B?Q2FuZGljZQ==?= Microsoft Word Document Management 2 17th Nov 2004 08:14 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:24 AM.