473,382 Members | 1,302 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

testing for association

36
Hi,

How can I test if a variable was associated with an object or not

for example
dim mytextbox as textbox
if mytextbox = Nothing then <=== this produces error
mytextbox = textbox0
else
set mytextbox = Nothing
endif
Jan 7 '07 #1
6 1413
ADezii
8,834 Expert 8TB
Hi,

How can I test if a variable was associated with an object or not

for example
dim mytextbox as textbox
if mytextbox = Nothing then <=== this produces error
mytextbox = textbox0
else
set mytextbox = Nothing
endif
You can use the IsEmpty() Function which returns a Boolean value indicating whether or not a Variable has been initialized:

Dim MyTextBox As TextBox
Set MyTextBox = Me![txtTest]
Debug.Print
Jan 7 '07 #2
ADezii
8,834 Expert 8TB
Hi,

How can I test if a variable was associated with an object or not

for example
dim mytextbox as textbox
if mytextbox = Nothing then <=== this produces error
mytextbox = textbox0
else
set mytextbox = Nothing
endif
You can use the IsEmpty() Function which returns a Boolean value indicating whether or not a Variable has been initialized:
Expand|Select|Wrap|Line Numbers
  1. Dim MyTextBox As TextBox
  2. Set MyTextBox = Me![txtTest]     'valid Text Box on frmTest
  3. Debug.Print IsEmpty(MyTextBox) ===> False
  4.  
  5. Debug.Print IsEmpty(MyTextBox2) ==> True
Jan 7 '07 #3
omozali
36
Hi,

How can I test if a variable was associated with an object or not

for example
dim mytextbox as textbox
if mytextbox = Nothing then <=== this produces error
mytextbox = textbox0
else
set mytextbox = Nothing
endif
I found out that typename(mytextbox) before association returns Nothing
and after association returns TextBox

The weird thing is this still produces error

if typename(mytextbox) = Nothing then
Jan 7 '07 #4
omozali
36
You can use the IsEmpty() Function which returns a Boolean value indicating whether or not a Variable has been initialized:
Expand|Select|Wrap|Line Numbers
  1. Dim MyTextBox As TextBox
  2. Set MyTextBox = Me![txtTest]     'valid Text Box on frmTest
  3. Debug.Print IsEmpty(MyTextBox) ===> False
  4.  
  5. Debug.Print IsEmpty(MyTextBox2) ==> True

But if you set mytextbox2 as textbox isnull would still returns true even if you don't associate it to a valid text box
Jan 7 '07 #5
omozali
36
I found out that typename(mytextbox) before association returns Nothing
and after association returns TextBox

The weird thing is this still produces error

if typename(mytextbox) = Nothing then

If found the answer

if Typename(mytextbox) = "Nothing" WORKS
Jan 7 '07 #6
NeoPa
32,556 Expert Mod 16PB
Hi,

How can I test if a variable was associated with an object or not

for example
dim mytextbox as textbox
if mytextbox = Nothing then <=== this produces error
mytextbox = textbox0
else
set mytextbox = Nothing
endif
You need to check 'Is Nothing' and you need to assign the object using 'Set'.
To rewrite your code above :
Expand|Select|Wrap|Line Numbers
  1. Dim mytextbox As TextBox
  2. If mytextbox Is Nothing Then  <=== this shouldn't
  3.     Set mytextbox = textbox0
  4. Else
  5.     Set mytextbox = Nothing
  6. EndIf
Jan 8 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: steve | last post by:
Hi, I just upgraded my php but ran into a problem. Never seen this before. Somehow it seems I lost php file association. When I do a http://localhost/something.php I get a prompt for dowload...
0
by: Stefano Noferi | last post by:
We are pleased to announce the foundation of the Zope Italia Association (AZI - Associazione Zope Italia). It was created by a couple of mailing list users in the last months (since march). ...
6
by: Justin F | last post by:
I have set up file association for my application (VB.Net). I'm having problems getting the filename that was double-clicked. On my machine at work, if the filename being passed in to the...
2
by: David | last post by:
Hi, I am trying to create a two way association between 2 objects. I intended to do it by having a pointer to each other but I am getting compilation errors. At the moment I can create both...
4
by: Rob | last post by:
I have an Access application that allows users to open up certain files from within Access (.doc files with automation, .pdf's with a pdf viewing form). Other formats, we want to use Internet...
1
by: JerryP | last post by:
Hi Experts, from my program I offer the user to launch different files from a directory (normaly in this directory are .txt files) - but sometimes other files may be in there - so if my program...
6
by: Nak | last post by:
Hi there, I am implementing file association from within my application, association that occurs after installation. Anyway, I remember a while back seeing a key in the registry that was used...
1
by: Doug Bell | last post by:
Hi, Suddenly clicking on an SLN File type will not open Visual Studio on my PC. Not sure what I have done. The association settings still look to be correct but I get an error message saying that...
39
by: windandwaves | last post by:
Hi Folk I have to store up to eight boolean bits of information about an item in my database. e.g. with restaurant drive-through facility yellow windows
1
by: CatchSandeepVaid | last post by:
I have posted this question in hibernate forums also.. As this forum is related to java, i am posting it here also ... In hibernate, presently one-to-one associations are fetched non-lazily... I...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.