access child control property

G

Guest

I need to check a the length of text of dropdown box control in child form.

For example:
If Len(Me!childform.MyDropdown.text) = 0 then
response = msgbox('You need enter some data', vbYesNo)
end if

I got can not reference control without set focus.

I may setfocus before if statement, but I have 5 controls to check in one if
statement. How can I set focus to 5 controls at same time.

Please let me know if I am not in right direction,

Thnaks millions,
 
J

John Vinson

I need to check a the length of text of dropdown box control in child form.

For example:
If Len(Me!childform.MyDropdown.text) = 0 then
response = msgbox('You need enter some data', vbYesNo)
end if

I got can not reference control without set focus.

I may setfocus before if statement, but I have 5 controls to check in one if
statement. How can I set focus to 5 controls at same time.

Please let me know if I am not in right direction,

Thnaks millions,

Well... I'd say no, you're not!

For one thing, a Subform might have 328,446 records in it. Which one
are you checking?

For another, you need to check the VALUE property of another textbox,
not its TEXT property.

I'd suggest doing this validity checking in the Subform's BeforeUpdate
event, rather than from any event on the mainform. This will occur for
every record entered, and you can simply use IsNull(Me!controlname) to
see if the field is null.

John W. Vinson[MVP]
 
G

Guest

Thanks for the message,
The control in the child form is unbounded.
I use the child form to group them.
It is my first mistake.
Are there any grouping components to use in VBA?
Are there any easier way to access the control in the child found unbounded?

Any information is great appreciated,

Souris
 
J

John Vinson

Thanks for the message,
The control in the child form is unbounded.
I use the child form to group them.
It is my first mistake.
Are there any grouping components to use in VBA?
Are there any easier way to access the control in the child found unbounded?

I guess I am totally lost here.

An unbound control's value will not be stored anywhere, and cannot be
used for grouping.

Could you explain the purpose of this control? What are you trying to
accomplish?

John W. Vinson[MVP]
 
G

Guest

Actually, it is a part of data entry form.
I have some controls in the child form to group them.
For example, the user information like user name, user status...etc.
Because I use the information to update all related records, user needs to
click save button to confirm save data.
I just want to validate the user input. if user leaves them blank then give
user a warning message and stop continuing.
Are there any way to validate the controls are empty in a child form from
parent form?
Thanks again,
 
J

John Vinson

Actually, it is a part of data entry form.
I have some controls in the child form to group them.
For example, the user information like user name, user status...etc.
Because I use the information to update all related records, user needs to
click save button to confirm save data.

The user name, user status, etc. should be stored in the user table.
It should certainly NOT be stored in "all related records" - only the
unique UserID should be stored there!

Am I still misunderstanding?
I just want to validate the user input. if user leaves them blank then give
user a warning message and stop continuing.
Are there any way to validate the controls are empty in a child form from
parent form?

No. Because in a child form there may be MANY records - potentially
millions of records. If you want to validate whether there is data
stored in a record in any table (whether that table is bound to a
mainform or a child form), the appropriate place to do that validation
is *either* in a validation rule (such as the field's Required
property) in the Table; or in the BeforeUpdate event of a Form; or
both, for insurance and clearer messages.

But my concern above still holds. If you are copying a user name, user
status, etc. from a mainform to all records in a subform...

DON'T.

It's WRONG. It's bad design.

John W. Vinson[MVP]
 

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