Problem updating unbound controls

L

LGC

Hello All:

I have a form bound to an updateable query. In the footer of the form I
have a row of unbound textbox controls that I use for data input. I trap
keystrokes on most of these controls to aid in data entry by restricting
invalid data and acting as an input mask. For example, on some of the
controls I trap the plus and minus keys to scroll through a list of valid
entries. Most of the data is numeric and this allows the user to enter all
of the data using the numeric keypad. One of the textbox control's data
source is set to a DLookup function using one of the textbox's value as
criteria.

Everything works as expected unless there are no records in the form's
record source. In this case I observe the following regarding the unbound
controls:

1. I get an error trying to reference the SelStart and SelLength properties
in the GotFocus event procedure. ("You can't reference a property or method
for a control unless the control has the focus") This error occurs when
tabbing into the control or setting the focus in code.

2. Any changes I make to the control's value in code does not appear until
select another application and then reselect the form.

3. The Lookup function does not work at all (with valid data as criteria),
even when reselecting the form.

Again, everything works fine when there is at least one record in the form's
record source. I would appreciate any input on a solution or what I may
have done to cause the problem.

Thank you.

LaVern
 
M

Michael, Cheng [MSFT]

Hi, LGC

From your descriptions, I understand that you would like to know why your
Access application will be error only when there is no error in Table. Have
I understood the issue correctly and completely? If there is anything I
misunderstood, please feel free to let me know.

However, I am not sure about you are using mdb or adp? I would like to know
what's the version you are using, Access 2000 / XP or 2003? Will it give
some error information when you open the Form while there is no record in
your table? Detailed information will be more helpful for us to get closer
to the resolution.

For your first questions, based on my understanding, you should get your
control SetFocus on Form_Load() first, As you could find Microsoft Visual
Basic Help that "the control must have the focus". You could have a look at
Microsoft Visual Basic Help, which could be launched by Visual Basic Editor
of Access, with Topic: SelStart Property and SelLength Property.

Also, there is the possibility that something is not porper with your
definition of data source.

If above could not be effective, it is appreciated that you could provide
me a sample database for me to reproduce your issue on my machine.

Thank you for your patience and cooperation. If you have any questions or
concerns, we are here to be of assistance!

Sincerely yours,

Michael Cheng
Microsoft Online Support
***********************************************************
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only, many thanks.
 
L

LGC

Thanks for responding, Michael.

I'm using Access 2000 (mdb) on a Win 2000 machine.

The only error I get is: "You can't reference a property or method for a
control unless the control has the focus". I understand that the SelLength
& SelStart properties are available only when the control has the focus.
Since the code that errors is in the GotFocus event procedure of the
control, I would presume that it does indeed have the focus.

The data source for the form is correct. There are no problems when there
is at least one record in the table from which the recordsource is based.

-LaVern
 
M

Michael, Cheng [MSFT]

Hi LaVem,

Thanks for you reply.

It is possible that you might error message when there is no record in your
recordsource. Some controls of Access need data to work properly.

I suggest you make "Data Entry" property of Form to be "Yes", which will
give a data record when a Form is open. I think it will make contribution
to your application.

If it still could not resolved your issue, I think you should do the
following as a workaround. Justify whether there is no record on the entry
of each function and. If data source is none, do nothing, otherwise, do
what it used to do.

For better trouble shooting, you could remove each of your control to see
whether it will turn to fine. Or it's appreciated if you could show me some
sample to make me reproduce it on my machine, which will be make us closer
to the resolution. I would be glad to do it for you.

Hope above two suggestions will work and if you have any questions or
concerns, don't hesitate to let me know.

Sincerely yours,

Michael Cheng
Microsoft Online Support
***********************************************************
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only, many thanks.
 
L

LGC

Michael,

Thank you for your thoughts.

The purpose of my unbound controls was for data entry. They needed to
function with no records in the recordset in order to enter the first
record.

I am now working on a work-around where I capture keyboard input on the form
level and the unbound controls never receive the focus.

I did have the form's DataEntry property set to No, which may have
contributed to the problem. I will reply back if I have any further
problems.

Thanks.

LaVern
 
M

Michael, Cheng [MSFT]

Hi LaVem,

I am glad to know that you have found a workaround.

If there is any question on it, please feel free to post in the group. We
are glad to be of assistance.

Sincerely yours,

Michael Cheng
Microsoft Online Support
***********************************************************
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only, many thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top