PC Review


Reply
Thread Tools Rate Thread

Calling a form in variable

 
 
Richard
Guest
Posts: n/a
 
      6th Mar 2010
Hi all,

I have some code that I want to share between various forms. My code looks
like this in a single form:

If Me!txtRef = "" Then
Exit Sub
End If

Where txtRef is a text box value entered by users

So I created a public procedure

Public Sub TestRef (ByVal FormName as Form)
If FormName!txtRef = "" Then
Exit Sub
End If
End sub

Then from my form frmTest I created an on click event: Call TestRef(frmTest)

I receive a 424 execution error, Object required.

What's wrong with this ?

Thanks for your help

Richard


 
Reply With Quote
 
 
 
 
Stefan Hoffmann
Guest
Posts: n/a
 
      6th Mar 2010
hi Richard,

On 06.03.2010 17:15, Richard wrote:
> Where txtRef is a text box value entered by users
>
> So I created a public procedure
>
> Public Sub TestRef (ByVal FormName as Form)
> If FormName!txtRef = "" Then
> Exit Sub
> End If
> End sub

This makes no sense as the Exit Sub only affects the TestRef method, not
the calling one.

> Then from my form frmTest I created an on click event: Call TestRef(frmTest)
> I receive a 424 execution error, Object required.

You cannot pass an object as ByVal and the name of your variable is also
not well choose. This should work:

Public Function TestReference(ByRef AForm As Access.Form) As Boolean

TestReference = (AForm.Controls("txtRef") <> vbNullString)

End Function


mfG
--> stefan <--
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
HDI: Pass calling form as variable into class Chris Hayes Microsoft Access VBA Modules 3 29th Nov 2008 10:55 AM
Calling a Form by a variable SurveyorinVA via AccessMonster.com Microsoft Access Form Coding 1 1st Feb 2008 09:58 PM
Passing calling form as a variable Ian Chappel Microsoft Access Forms 4 16th Jul 2007 09:58 AM
Calling a variable from another form rblivewire Microsoft Access 3 1st May 2007 02:11 AM
Calling variable from user form Geraldon Microsoft Excel Programming 2 9th Feb 2004 03:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:16 PM.