check if textboxA exists in a form (1 Viewer)

Lcrosspt

New member
Local time
Yesterday, 18:36
Joined
Mar 12, 2007
Messages
5
I have a dynamic form that loads different textboxs depending on several vars.
i want to use it to update a table but cant check if textboxA.value exist, because if it doesn't it just throws a error.
Is there any other way of doing this? Thanks.
 

Minty

AWF VIP
Local time
Today, 01:36
Joined
Jul 26, 2013
Messages
10,355
It's not normal to actually populate a forms controls dynamically. Normal practice is to hide and make visible the controls you need.

If the form is used in a runtime or accde file it probably won't work, as I assume you are opening the form in design mode to achieve this?
 

Lcrosspt

New member
Local time
Yesterday, 18:36
Joined
Mar 12, 2007
Messages
5
well the form is set with"screen.activeform"and then depending in the name of the form it loads the right one.
then i have to check all possible textfields in all forms to update the table.
problem is when i try to check if the field value is text... if the textbox doesn't exists it returns "2465 Application-defined or object-defined error"
i tried ismissing but no luck
 

Minty

AWF VIP
Local time
Today, 01:36
Joined
Jul 26, 2013
Messages
10,355
So it's actually a different form, not different controls ?
Can you post up the code used to load the form?

You could also iterate through form controls using the controls collection.
 

isladogs

MVP / VIP
Local time
Today, 01:36
Joined
Jan 14, 2017
Messages
18,186
if the textbox doesn't exists it returns "2465 Application-defined or object-defined error"

You can easily hide the error by adding this line in your error handler code
Code:
If err=2465 Then Exit Sub

or possibly
Code:
If err=2465 Then Resume Next

However, this isn't recommended.
It would be far better to fix the issue causing the error
 

Lcrosspt

New member
Local time
Yesterday, 18:36
Joined
Mar 12, 2007
Messages
5
Minty not sure what the "code used to load the form" is... i just have this in a main form button
Code:
frm = gotoform.value ' textbox field by combo with name of form to go 
DoCmd.OpenForm frm, acNormal
everything is ok with loading this from, the problem cames when i try to check if
screen.activeform.textbox.value isnotnum (call my sub in module, and that's why use screen.activeform.name...because the name of the form is not always the same)

ridders - thanks for the workaround,i 'll use it in last resource, but i can't figure out what is causing the error...
 

Minty

AWF VIP
Local time
Today, 01:36
Joined
Jul 26, 2013
Messages
10,355
Okay - you should pass the form name to your sub when it's called. Active form is not very reliable.
And if you passed the controls name with the form name, your checking code become simple. It sounds like you have probably tried to save code writing when you actually are making your life harder.
 

Mark_

Longboard on the internet
Local time
Yesterday, 18:36
Joined
Sep 12, 2017
Messages
2,111
Any reason the called form doesn't do the check?

Code:
IF nz(Me.textboxA,"") = "" THEN

on the form that does have TextBoxA would be easy to code for.
 

Lcrosspt

New member
Local time
Yesterday, 18:36
Joined
Mar 12, 2007
Messages
5
Minty your right i was chasing my own butt...:banghead:

you just send me in the right track thanks
 

Users who are viewing this thread

Top Bottom