2105 error can't go to specific record on SetFocus

bonmot.srf

Registered User.
Local time
Today, 04:47
Joined
May 26, 2010
Messages
11
This is a recurrent error that bugs the cr** out of me. Sometimes this form works great and then for some reason it fails.

The form's record source is a query which runs on an unbound field's Update event:

The 2105 error occurs when the form loads and it tries to setfocus on the queries input field "txtFieldID"

Private Sub Form_Load()
DoCmd.MoveSize 1, 1, 6600, 3400
txtFieldID.SetFocus
End Sub

Private Sub txtFieldID_AfterUpdate()
Me.Requery
DoCmd.OpenForm "frmFieldID", acNormal
Forms!frmFieldID.cboFieldID = Me.[txtFieldID]
Forms!frmFieldID.Requery
DoCmd.OpenForm "frmFieldIDStudyDirector", acNormal
'Forms!frmFieldIDStudyDirector.Requery
End Sub

Here's the query & a link to the database.

SELECT tblFieldIDsPRNUMsNumeric.FLD_ID, tblFieldIDsPRNUMsNumeric.PRNUM AS Project, tblFieldIDsPRNUMsNumeric.prnum_num, food_master.pesticide, food_master.commodity
FROM food_master INNER JOIN tblFieldIDsPRNUMsNumeric ON food_master.prnum=tblFieldIDsPRNUMsNumeric.prnum_num
WHERE (((tblFieldIDsPRNUMsNumeric.FLD_ID)=[forms]![frmFieldIDinput]![txtFieldID]));


http://wrir4.ucdavis.edu/data/fieldidtest.zip

Any ideas out there?

Thanks,
 
Is the unbound control on the form that is being opened or on another form?
 
The unbound control is on the original form.
 
Would an option be to have the Form open without a RecordSource or a Fake source and a when there is data in the unbound text box control the forms record source is changed to the query that is looking for data from the text box and then re query.
 
Private Sub txtFieldID_AfterUpdate()
Me.Requery
DoCmd.OpenForm "frmFieldID", acNormal
Forms!frmFieldID.cboFieldID = Me.[txtFieldID]
Forms!frmFieldID.Requery

DoCmd.OpenForm "frmFieldIDStudyDirector", acNormal
'Forms!frmFieldIDStudyDirector.Requery
End Sub
Your problem lies within those two lines. Comment out those two lines and see the outcome.
 
I have commented out those lines since they actually action on an external form. Commented out the recordsource still doesn't resolve.

I've tried to get this VBA form of my query to work but it's not quite correct:

Me.Recordset = "SELECT tblFieldIDsPRNUMsNumeric.FLD_ID, tblFieldIDsPRNUMsNumeric.PRNUM AS Project, tblFieldIDsPRNUMsNumeric.prnum_num, food_master.pesticide, food_master.commodity " & _
"FROM food_master INNER JOIN tblFieldIDsPRNUMsNumeric ON food_master.prnum=tblFieldIDsPRNUMsNumeric.prnum_num " & _
"WHERE (((tblFieldIDsPRNUMsNumeric.FLD_ID)=[forms]![frmFieldIDinput]![txtFieldID])); "
 
If that didn't pin-down the problem then there's more to your code/record source that's also a contributor to the problem.

The code you've just written is incorrect. Post your db let's have a look.
 
Like I mentioned, there's something wrong with your record source. Remove the criteria in the query and the error wouldn't appear.
 
Why does your recordsource for frmFieldIDInput reference a control on itself? That doesn't make sense to me. That is the problem. Get rid of that Where clause and the problem goes away.
 
Hi... thanks for the suggestions. Yes if I remove the criteria the problem goes away, but the whole purpose of the FieldIDinput form is to pass one specific record to the second form.

To reproduce the error try opening the frmFieldIDinput form
 
Can you put the form into another main form which just has the one unbound text box control.
The Mainform opens and the subforms query refers to the mainform text box
 
So... maybe there's another way of doing this that I'm missing.

The goal is input a fieldID into the unbound control txtFieldID, then the other fields on frmInputFieldID are the fields associated with that particular fieldID.

I've tried putting the txtFieldID into a header but this also doesn't work.

Ideas? I'm sure I'm missing something obvious here

/;)
 
Or you use a combo box to select a record and it moves to it. You can use the wizard when adding a combo box if you select the third option - find a record based on my control.
 
Bob... thanks that worked, now I'll pick it apart & apply it to the remainder of my project.

Kudos
 

Users who are viewing this thread

Back
Top Bottom