I am developing an Access 2007 "project" (ADP) as a front-end to a SQL Server 2005 Express database.
I have a "continuous" Access Form that lists the records in a Table before they are printed on an Invoice or Credit Note. These rows of data can be modified or new rows added within the Form.
In the Footer of the Form I have a large Tab Control with several Tab Pages. Each of these Tab Pages contains further Combo controls and Text Box controls that govern what will be printed on the Invoice or Credit Note when it is eventually printed.
Normally this Form displays rows of records in the Detail Section when it is first opened, and I have no problems as I move from Tab Page to Tab Page in the Footer. However, if there are no records displayed to begin with, I get the following run-time error when I open a Tab Page and the focus is placed on a Text Box in the page.
Run-time error 2185
You can't reference a property or method for a control unless the control has the focus.
This happens in Text Boxes that contain messages that might be printed on the Invoice or Credit. It happens in the "On Enter" event procedure where I set ".SelStart" and ".SelLength" to 0, to position the text cursor at the first character of the text rather than selecting all the text.
I do not get this error if the Tab Page's first control is a Combo Box or if it is a Text Box for which I have not established an "On Enter" sub procedure. The cursor seems to sit in these controls OK. If I add a row of data to the Form's Detail section before opening the Tab Pages that have the "On Enter" procedures I do not get the error message.
Can someone explain to me why I get this error message when my Form is empty? I have another text control called ".txtLineCount" that I use to display the number of data lines. Even when I add the expression :
"If Nz(Me.TxtLineCount, 0) > 0 then" in my "On Enter" event procedure I get the error message at that point.
Many thanks. Colin.