A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Missing Operator



 
 
Thread Tools Display Modes
  #1  
Old September 29th, 2005, 08:27 PM
DS
external usenet poster
 
Posts: n/a
Default Missing Operator

Does anyone know what the missing operator is?
Thanks
DS

Private Sub Form_Open(Cancel As Integer)
Forms!MenuItems.RecordsetClone.FindFirst "[MenuCatID] = " &
Forms!MenuItems![Text49] & ""
Forms!MenuItems.Bookmark = Forms!MenuItems.RecordsetClone.Bookmark
End Sub
  #2  
Old September 29th, 2005, 09:27 PM
Justin Hoffman
external usenet poster
 
Posts: n/a
Default

"DS" wrote in message
...
Does anyone know what the missing operator is?
Thanks
DS

Private Sub Form_Open(Cancel As Integer)
Forms!MenuItems.RecordsetClone.FindFirst "[MenuCatID] = " &
Forms!MenuItems![Text49] & ""
Forms!MenuItems.Bookmark = Forms!MenuItems.RecordsetClone.Bookmark
End Sub



I can't quite imagine why opening this form (which presumably is not
'MenuItems') causes the MenuItems form to move to a particular record, the
ID of which was already showing on the form itself - but I assume you know
what you are doing there.
Perhaps you should make sure you have a valid MenuCatID before you proceed
with your code. In the example I give I check to see the form is open, then
try to get a non-zero long integer before I do a FindFirst. I also check
the .NoMatch criteria before I sync the bookmark of the recordset with the
recordsetclone object. I also set cancel to true so that this form will not
open unless it finds the matching record. I also include some more
generalised error-handling for unexpected errors.
I can't swear it will do what you need since I don't have all the details
(eg should MenuCatID be a non-zero long integer?) - but it might point you
in the right direction:

Private Sub Form_Open(Cancel As Integer)

On Error GoTo Err_Handler

Dim lngID As Long

Cancel = True

If IsFormLoaded("MenuItems") Then
lngID = CLng(Nz(Forms!MenuItems!Text49, 0))
End If

If lngID 1 Then
MsgBox "Missing ID from form 'MenuItems'", vbExclamation
Exit Sub
End If

With Forms!MenuItems.RecordsetClone

.FindFirst "MenuCatID=" & CStr(lngID)

If Not .NoMatch Then
Forms!MenuItems.Bookmark = .Bookmark
Cancel = False
Else
MsgBox "Cannot locate record", vbExclamation
End If

End With

Exit_Handler:
Exit Sub

Err_Handler:
MsgBox Err.Description, vbExclamation, "Error No: " & Err.Number
Resume Exit_Handler

End Sub

Private Function IsFormLoaded(strName As String)
IsFormLoaded = (SysCmd(acSysCmdGetObjectState, acForm, strName) 0)
End Function


  #3  
Old September 29th, 2005, 09:33 PM
DS
external usenet poster
 
Posts: n/a
Default

Justin Hoffman wrote:
"DS" wrote in message
...

Does anyone know what the missing operator is?
Thanks
DS

Private Sub Form_Open(Cancel As Integer)
Forms!MenuItems.RecordsetClone.FindFirst "[MenuCatID] = " &
Forms!MenuItems![Text49] & ""
Forms!MenuItems.Bookmark = Forms!MenuItems.RecordsetClone.Bookmark
End Sub




I can't quite imagine why opening this form (which presumably is not
'MenuItems') causes the MenuItems form to move to a particular record, the
ID of which was already showing on the form itself - but I assume you know
what you are doing there.
Perhaps you should make sure you have a valid MenuCatID before you proceed
with your code. In the example I give I check to see the form is open, then
try to get a non-zero long integer before I do a FindFirst. I also check
the .NoMatch criteria before I sync the bookmark of the recordset with the
recordsetclone object. I also set cancel to true so that this form will not
open unless it finds the matching record. I also include some more
generalised error-handling for unexpected errors.
I can't swear it will do what you need since I don't have all the details
(eg should MenuCatID be a non-zero long integer?) - but it might point you
in the right direction:

Private Sub Form_Open(Cancel As Integer)

On Error GoTo Err_Handler

Dim lngID As Long

Cancel = True

If IsFormLoaded("MenuItems") Then
lngID = CLng(Nz(Forms!MenuItems!Text49, 0))
End If

If lngID 1 Then
MsgBox "Missing ID from form 'MenuItems'", vbExclamation
Exit Sub
End If

With Forms!MenuItems.RecordsetClone

.FindFirst "MenuCatID=" & CStr(lngID)

If Not .NoMatch Then
Forms!MenuItems.Bookmark = .Bookmark
Cancel = False
Else
MsgBox "Cannot locate record", vbExclamation
End If

End With

Exit_Handler:
Exit Sub

Err_Handler:
MsgBox Err.Description, vbExclamation, "Error No: " & Err.Number
Resume Exit_Handler

End Sub

Private Function IsFormLoaded(strName As String)
IsFormLoaded = (SysCmd(acSysCmdGetObjectState, acForm, strName) 0)
End Function


The code works fine when I run it from a button.

Me.RecordsetClone.FindFirst "[MenuCatID] = " & Me![Text49] & ""
Me.Bookmark = Me..RecordsetClone.Bookmark

but not on the onopen of a form. Is this on the wrong place?

I'm opening a second form based on 2 criteria This only shows one
record. I need to have them all.

If I remove the second criteria I get all of the records I need but it
goes to the first record not the selected record.

Is this clearer?
Thnaks
DS
  #4  
Old September 29th, 2005, 09:49 PM
Justin Hoffman
external usenet poster
 
Posts: n/a
Default

"DS" wrote in message
...
Justin Hoffman wrote:
"DS" wrote in message
...

Does anyone know what the missing operator is?
Thanks
DS

Private Sub Form_Open(Cancel As Integer)
Forms!MenuItems.RecordsetClone.FindFirst "[MenuCatID] = " &
Forms!MenuItems![Text49] & ""
Forms!MenuItems.Bookmark = Forms!MenuItems.RecordsetClone.Bookmark
End Sub




I can't quite imagine why opening this form (which presumably is not
'MenuItems') causes the MenuItems form to move to a particular record,
the ID of which was already showing on the form itself - but I assume you
know what you are doing there.
Perhaps you should make sure you have a valid MenuCatID before you
proceed with your code. In the example I give I check to see the form is
open, then try to get a non-zero long integer before I do a FindFirst. I
also check the .NoMatch criteria before I sync the bookmark of the
recordset with the recordsetclone object. I also set cancel to true so
that this form will not open unless it finds the matching record. I also
include some more generalised error-handling for unexpected errors.
I can't swear it will do what you need since I don't have all the details
(eg should MenuCatID be a non-zero long integer?) - but it might point
you in the right direction:

Private Sub Form_Open(Cancel As Integer)

On Error GoTo Err_Handler

Dim lngID As Long

Cancel = True

If IsFormLoaded("MenuItems") Then
lngID = CLng(Nz(Forms!MenuItems!Text49, 0))
End If

If lngID 1 Then
MsgBox "Missing ID from form 'MenuItems'", vbExclamation
Exit Sub
End If

With Forms!MenuItems.RecordsetClone

.FindFirst "MenuCatID=" & CStr(lngID)

If Not .NoMatch Then
Forms!MenuItems.Bookmark = .Bookmark
Cancel = False
Else
MsgBox "Cannot locate record", vbExclamation
End If

End With

Exit_Handler:
Exit Sub

Err_Handler:
MsgBox Err.Description, vbExclamation, "Error No: " & Err.Number
Resume Exit_Handler

End Sub

Private Function IsFormLoaded(strName As String)
IsFormLoaded = (SysCmd(acSysCmdGetObjectState, acForm, strName) 0)
End Function


The code works fine when I run it from a button.

Me.RecordsetClone.FindFirst "[MenuCatID] = " & Me![Text49] & ""
Me.Bookmark = Me..RecordsetClone.Bookmark

but not on the onopen of a form. Is this on the wrong place?

I'm opening a second form based on 2 criteria This only shows one record.
I need to have them all.

If I remove the second criteria I get all of the records I need but it
goes to the first record not the selected record.

Is this clearer?
Thnaks
DS




If you write more lines of code, taking it step by step, your problem may
become apparent. Get the value of Me![Text49] and explicitly convert it
into a long integer, before you move on. Either use a breakpoint and step
through it or put a messagebox on the screen to show you what this value is.
My guess is that, if there is a difference in behaviour when calling from
the Open event and a button's Click event, then [Text49] is not yet loaded
with the right value during the Open event. Once the form has opened,
loaded and you click the button, the expected value is there.


  #5  
Old September 29th, 2005, 09:58 PM
DS
external usenet poster
 
Posts: n/a
Default

Justin Hoffman wrote:
"DS" wrote in message
...

Justin Hoffman wrote:

"DS" wrote in message
...


Does anyone know what the missing operator is?
Thanks
DS

Private Sub Form_Open(Cancel As Integer)
Forms!MenuItems.RecordsetClone.FindFirst "[MenuCatID] = " &
Forms!MenuItems![Text49] & ""
Forms!MenuItems.Bookmark = Forms!MenuItems.RecordsetClone.Bookmark
End Sub



I can't quite imagine why opening this form (which presumably is not
'MenuItems') causes the MenuItems form to move to a particular record,
the ID of which was already showing on the form itself - but I assume you
know what you are doing there.
Perhaps you should make sure you have a valid MenuCatID before you
proceed with your code. In the example I give I check to see the form is
open, then try to get a non-zero long integer before I do a FindFirst. I
also check the .NoMatch criteria before I sync the bookmark of the
recordset with the recordsetclone object. I also set cancel to true so
that this form will not open unless it finds the matching record. I also
include some more generalised error-handling for unexpected errors.
I can't swear it will do what you need since I don't have all the details
(eg should MenuCatID be a non-zero long integer?) - but it might point
you in the right direction:

Private Sub Form_Open(Cancel As Integer)

On Error GoTo Err_Handler

Dim lngID As Long

Cancel = True

If IsFormLoaded("MenuItems") Then
lngID = CLng(Nz(Forms!MenuItems!Text49, 0))
End If

If lngID 1 Then
MsgBox "Missing ID from form 'MenuItems'", vbExclamation
Exit Sub
End If

With Forms!MenuItems.RecordsetClone

.FindFirst "MenuCatID=" & CStr(lngID)

If Not .NoMatch Then
Forms!MenuItems.Bookmark = .Bookmark
Cancel = False
Else
MsgBox "Cannot locate record", vbExclamation
End If

End With

Exit_Handler:
Exit Sub

Err_Handler:
MsgBox Err.Description, vbExclamation, "Error No: " & Err.Number
Resume Exit_Handler

End Sub

Private Function IsFormLoaded(strName As String)
IsFormLoaded = (SysCmd(acSysCmdGetObjectState, acForm, strName) 0)
End Function



The code works fine when I run it from a button.

Me.RecordsetClone.FindFirst "[MenuCatID] = " & Me![Text49] & ""
Me.Bookmark = Me..RecordsetClone.Bookmark

but not on the onopen of a form. Is this on the wrong place?

I'm opening a second form based on 2 criteria This only shows one record.
I need to have them all.

If I remove the second criteria I get all of the records I need but it
goes to the first record not the selected record.

Is this clearer?
Thnaks
DS





If you write more lines of code, taking it step by step, your problem may
become apparent. Get the value of Me![Text49] and explicitly convert it
into a long integer, before you move on. Either use a breakpoint and step
through it or put a messagebox on the screen to show you what this value is.
My guess is that, if there is a difference in behaviour when calling from
the Open event and a button's Click event, then [Text49] is not yet loaded
with the right value during the Open event. Once the form has opened,
loaded and you click the button, the expected value is there.


thanks I'll give it a try
ds
  #6  
Old September 29th, 2005, 10:17 PM
DS
external usenet poster
 
Posts: n/a
Default

Justin Hoffman wrote:
"DS" wrote in message
...

Justin Hoffman wrote:

"DS" wrote in message
...


Does anyone know what the missing operator is?
Thanks
DS

Private Sub Form_Open(Cancel As Integer)
Forms!MenuItems.RecordsetClone.FindFirst "[MenuCatID] = " &
Forms!MenuItems![Text49] & ""
Forms!MenuItems.Bookmark = Forms!MenuItems.RecordsetClone.Bookmark
End Sub



I can't quite imagine why opening this form (which presumably is not
'MenuItems') causes the MenuItems form to move to a particular record,
the ID of which was already showing on the form itself - but I assume you
know what you are doing there.
Perhaps you should make sure you have a valid MenuCatID before you
proceed with your code. In the example I give I check to see the form is
open, then try to get a non-zero long integer before I do a FindFirst. I
also check the .NoMatch criteria before I sync the bookmark of the
recordset with the recordsetclone object. I also set cancel to true so
that this form will not open unless it finds the matching record. I also
include some more generalised error-handling for unexpected errors.
I can't swear it will do what you need since I don't have all the details
(eg should MenuCatID be a non-zero long integer?) - but it might point
you in the right direction:

Private Sub Form_Open(Cancel As Integer)

On Error GoTo Err_Handler

Dim lngID As Long

Cancel = True

If IsFormLoaded("MenuItems") Then
lngID = CLng(Nz(Forms!MenuItems!Text49, 0))
End If

If lngID 1 Then
MsgBox "Missing ID from form 'MenuItems'", vbExclamation
Exit Sub
End If

With Forms!MenuItems.RecordsetClone

.FindFirst "MenuCatID=" & CStr(lngID)

If Not .NoMatch Then
Forms!MenuItems.Bookmark = .Bookmark
Cancel = False
Else
MsgBox "Cannot locate record", vbExclamation
End If

End With

Exit_Handler:
Exit Sub

Err_Handler:
MsgBox Err.Description, vbExclamation, "Error No: " & Err.Number
Resume Exit_Handler

End Sub

Private Function IsFormLoaded(strName As String)
IsFormLoaded = (SysCmd(acSysCmdGetObjectState, acForm, strName) 0)
End Function



The code works fine when I run it from a button.

Me.RecordsetClone.FindFirst "[MenuCatID] = " & Me![Text49] & ""
Me.Bookmark = Me..RecordsetClone.Bookmark

but not on the onopen of a form. Is this on the wrong place?

I'm opening a second form based on 2 criteria This only shows one record.
I need to have them all.

If I remove the second criteria I get all of the records I need but it
goes to the first record not the selected record.

Is this clearer?
Thnaks
DS





If you write more lines of code, taking it step by step, your problem may
become apparent. Get the value of Me![Text49] and explicitly convert it
into a long integer, before you move on. Either use a breakpoint and step
through it or put a messagebox on the screen to show you what this value is.
My guess is that, if there is a difference in behaviour when calling from
the Open event and a button's Click event, then [Text49] is not yet loaded
with the right value during the Open event. Once the form has opened,
loaded and you click the button, the expected value is there.


Patience is a virtue! I put the code on the first form and that worked
fine. Thanks
DS
 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with syntax error message, says its missing operator help koi Using Forms 1 September 9th, 2005 08:47 PM
unable to repair inobox Sudheer Mumbai General Discussion 1 February 20th, 2005 11:55 AM
Missing operator Mitch New Users 3 September 9th, 2004 09:52 PM
Converting T-SQL -> Access give Syntax error (missing operator) inquery expression Andrew John Running & Setting Up Queries 3 September 1st, 2004 12:06 PM
Missing Operator Problem Benjamin Running & Setting Up Queries 4 August 26th, 2004 01:34 PM


All times are GMT +1. The time now is 11:04 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.