Record Set find first not working

mba_110

Registered User.
Local time
Today, 10:56
Joined
Jan 20, 2015
Messages
280
Hi

Below combo box after update event is not working

Code:
Private Sub cboEntryNo_AfterUpdate()
Me.Recordset.FindFirst "EntryNo = " & Nz(cboEntryNo, 0)
End Sub

form record source is tblEntries

No records are showing in text boxes for that EntryNo (PK) of tblEntries.

Combo box row source
Code:
SELECT [QryCash&BankEntrySelection].EntryNo FROM [QryCash&BankEntrySelection];

cboEntryNo is unbound combo box which select the EntryNo from query.

I want on form after update of combo box to show the selected entry row information on form.
 
First guess will be that the combobox has multiple columns (possibly hidden) and you are returning the wrong bound column. Therefore it cannot find it. Debug.print to verify.
 
don't use Findfirst, instead just filter all the records,
then you can see all the correct values:

Code:
sub txtFind_Afterupdate()
If IsNull(txtFind) Then
   Me.FilterOn = False
Else
   Me.Filter = "[ItemName] = '" & me.txtFind & "'"
   Me.FilterOn = True
End If
end sub
 
I don't think you have the complete code. To go to that record you need to set the form''s bookmark to the one of the recordset''s.
Dim varID
Recordset. Findfirst. ..
VarÌD=recordset.bookmark
Me.bookmark=VarID

Look at the code the built in wizard adds when creating a combo to find records.
Cheers,
Vlad
 
I don't think you have the complete code.
That is not correct. If you use the Recordset property then it will move to the record automatically with a find first if the record is found. If you use the RecordsetClone property it will not automatically move. You then get the clone bookmark and set it to the recordset bookmark and it will move the recordset. You are mixing the two approaches.
 
FilterON and Off is complete disaster, its deleting my fields information.

Code:
If IsNull(me.cboEntryNo) Then
   Me.FilterOn = False
Else
   Me.Filter = "[EntryNo] = " & me.cboEntryno & ""
   Me.FilterOn = True
End If

Please provide the correct piece of code, i did try with recordset.findfirst but its not pulling anything.

I know the trick of multiple hidden columns in combo box but, if its in small qty and also its not ideal to use temporary solutions.

strong code like findfirst can do it easily, but i am missing something in that.
 
it is either numeric
Code:
"[EntryNo] = " & me.cboEntryno
or text
Code:
"[EntryNo] = '" & me.cboEntryno & "'"


Please learn how to use debug.print to debug your own code. It will help a lot. You should do
debug.print me.filter
to verify your string is correct.
 
I doubt this very much
its deleting my fields information

See the link in my signature for error handling and debugging info.
 
Yes it is not deleting. You filter is bad since nothing matches the filter it returns no records.
Your filter is bad for one of a couple of reasons
1) the field names are incorrect
2) the field is text and you are not enclosing it in single quotes
3) the combo is not returning what you think it is
debug.print and we can answer these questions.
 
Ok, now i have attached the form with tables and queries i did try all but not succeed.

I also dont know why its not working as other forms are working correctly with same procedure.

Because may i have some extra fields on forms header, but it ok to have on header?
 

Attachments

You had the form set to data entry, check the updated file to see if OK.
Cheers,
Vlad
 

Attachments

Users who are viewing this thread

Back
Top Bottom