Problem with FindFirst and GroupOptions! Everybody help me please!!

jokelogpop

Registered User.
Local time
Today, 00:54
Joined
Oct 16, 2004
Messages
22
HI all!

I have this code:

Private Sub cmdGoToBlkRecord_Click() 'Find Blank Record Acording to the number of Toggle Button.
Dim NumOfComputer As Variant
NumOfComputer = FrameToggle ' Dimention the value of Toggle button
MsgBox "The Number of Toggle is NumOfComputer "
' I want to search the record acording to the Number of Toggle buttons

Me.RecordsetClone.FindFirst "[fldNumComp] = NumOfComputer And Not Isnull([FirstTime]) And Isnull([SecondTime])"
Me.Bookmark = Me.RecordsetClone.Bookmark
End Sub

If I leave out the condition "[fldNumComp] = NumOfComputer ", It work well. But I realy need this Option. Can you give me a guide?

Sory for my bother!!
 
Have you tried declaring NumOfComputer as an Integer instead of a Variant?
 
I agree with the Integer idea, but I am trying to figure Fram Toggle and were it is being used. Just a thoght. hth.
 
Hi!!
I am trying change the the Variant into Interger but it still has error.
Can I use Me.FrameToggle.Value? When I use this expression, I got the error:
H2.JPG

It is seem that the [fldNumComp] condition accept only number value ex. "[fldNumComp] = 2 And ...". How can I solve it.
 
Try:

Me.RecordsetClone.FindFirst "[fldNumComp] = " & NumOfComputer & " And Not Isnull([FirstTime]) And Isnull([SecondTime])"
 
Thanks Pbaldy!
How should I thank to you!!! It work very well. But I don't know how to put it to the If ... Else. My idea is that If the action find the record, it locate here_it is OK, Else, the other action will create a new record! (I know how to code to create a new record. If you know how to code it into If ... Else., please give me a guide.)
I find in the Access Help and found this code:
If rst.NotMatch then
.....
End IF
I try to use this code but Access warns that NotMatch is not a method!
What should I do???
 
It's NoMatch, not NotMatch.
 
Thanks you one more Pbaldy!
Yes, It is Nomatch not Notmach. Now it work well.!!
I am sorry! I have a tupic question. I don't understand the functions of two symbol & & in the code you wrote.
Me.RecordsetClone.FindFirst "[fldNumComp] = " & NumOfComputer & " And Not Isnull([FirstTime]) And Isnull([SecondTime])"
Can you explain more about the differences between the code "[fldNumComp] = NumOfComputer " and "[fldNumComp] = " & NumOfComputer & " ......". If I want to get the value of a List Box, is there any changes in the code?
I know my question is so sily but I realy want to know.
Thank you very much
---- Minh Hien ---
 
Text (even variables) within the quotes will be interpreted literally, so:

"[fldNumComp] = NumOfComputer "

will be evalutated as exactly that. The value of fldNumComp would have to be "NumOfComputer" to find a match (the name of the variable, not its value). You have to get the variable outside the quotes to have Access evaluate its value, and the "&" ties it all together.

So, in this case the value of NumOfComputer will be evaluated, then included in the string. If NumOfComputer had a value of 7, this:

"[fldNumComp] = " & NumOfComputer & " ......".

would be evaluated by Access as

"[fldNumComp] = 7 AND..."

That help, or make it more confusing? :eek:
 
Hi pbaldy!
I understand what you explained but I cannot apply for a List Box. My code is:
Me.RecordsetClone.FindFirst "[fldNumComp] = " & List_NumOfComputer & " And Not Isnull([FirstTime]) And Isnull([SecondTime])"
List_NumOfComputer is listBox name. I think the value of list box will be "text" and evalutated like:
Me.RecordsetClone.FindFirst "[fldNumComp] = " & "Comp 01" & " And Not Isnull([FirstTime]) And Isnull([SecondTime])".
Is it right pbaldy?? I hope I am right but it does not work any more!!!
 
Text values must be surrounded by single quotes, so try:

Me.RecordsetClone.FindFirst "[fldNumComp] = '" & List_NumOfComputer & "' And Not Isnull([FirstTime]) And Isnull([SecondTime])"

This presumes that the listbox is not set to either of the multiselect settings. It will only work if it's single select.
 

Users who are viewing this thread

Back
Top Bottom