I have a form (under construction) that is based on a query. The query works well and has no errors. I can effectively input data through the query.
The form, however, has numerous #name? errors in textboxes. The textboxes with errors don't seem any different to me then those without errors. All fields with errors are taken directly from the drop-down list of fields from the source query. Those fields even have data in them when viewed directly through the query.
A snapshot of the form is attached. Any thoughts on why those fields have errors would be appreciated. I need to resolve this quickly.
If you could include a sample database I could probably find what is wrong. The only thing I can suggest is the fact that you have an invalid name of something somewhere. If it is a calculated field one of the calculations is probably wrong, which is where I think ghozy was going.
I will tell you something more weird. when open your forms control source query in form's design mode and cahnge something and reverse changes back. then save back. #names error disapears. I will add database file back so you can check. it is magicaly fixed itself.
I noticed that the tlkpAirlines table was missing so I put that in in case something hinky was happening. Everything looks fine and that didn't help at all.
I was able to recreate your problem exactly. I didn't see anything else "wrong" with your form but I noticed I could "fix" it if I did this.
Go into design mode in your form.
Go to the properties window and click the Data tab.
Click in the field with the datasource name (the query) and then click the little button to the right that appears in order to launch the query.
When the QBE grid (the design window) shows up, press the Exclamation mark to run the query.
Close the query window.
Save your form.
Open it up again.
It seems to "find" the fields once you run the query from inside the form.
I found that once I did that, the #Name fields all behaved. If I saved the form, exited the database and went back in, it still worked fine.
OK everyone...I've narrowed down the problem to the VB code behind the form. When I change the form's 'has module' property to NO, then the #name? errors disappear.
I'd like your help in identifying the problem, and I can post the sample DB with the code behind it, but you'll need the other tables for the code to make sense. However, I'm reluctant to publicly post the entire DB.
I can't think anything else about this problem. I believe it is a field reference problem. try this:
* choose another query for your form's record source. save it.
*open it back and change it back to old query. save it.
* try it.
I figured it out...I have a Command Button in the footer called cmdClear. Here is the code behind its Click event:
Public Sub cmdClear_Click()
'Clear other search fields
Me.cboPassengerLookup = ""
Me.cboRunNumLookup = ""
'Clear filters and go to new record
varSQL = "SELECT * FROM tblRuns"
Forms![frmReservations].RecordSource = varSQL
DoCmd.GoToRecord , , acNewRec
'Move focus to RunDate field
The problem with this is that I STUPIDLY reset the dataset to tblRuns instead of qryReservations.
The reason this caused a problem immediately upon using the form is my GENIUS PLACEMENT of a call for that Sub in the form's Open event.
So, everytime the form opened, the comand buitton was being procedurally 'clikced' and was changing the data source!!!