By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,290 Members | 1,551 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,290 IT Pros & Developers. It's quick & easy.

What Do I Use Instead of Me. in a Module?

P: n/a
All,

I'm trying to move this code (which I bastardized, thanks!) from the
form where I have successfully implemented it to a Module, so I can
implement it for all of the appropriate forms in my app.

Of course, I'm getting an error because I can't use Me. in a Module.
I read the many posts explaining why I can't, but did not find an
answer as to how to resolve this.

Any suggestions?

Thanks,

Patrick

************************************************** ************************************************** **********
Public Sub Clear_All()
On Error GoTo Err_BTN_Clear_All_Click

Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Tag <"NoDel" And TypeOf ctl Is TextBox Or TypeOf ctl Is
ComboBox Or _
TypeOf ctl Is ListBox Or TypeOf ctl Is CheckBox Then
If Left(ctl.ControlSource, 1) <"=" Then
ctl.Value = Null
End If
End If
Next

Exit_BTN_Clear_All_Click:
Exit Sub

Err_BTN_Clear_All_Click:
MsgBox Err.Description
Resume Exit_BTN_Clear_All_Click

End Sub

************************************************** ************************************************** **********
Dec 14 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Public Sub Clear_All(ByRef CallingForm as Form)
On Error GoTo Err_BTN_Clear_All_Click

Dim ctl As Control
For Each ctl In CallingForm.Controls
If ctl.Tag <"NoDel" And TypeOf ctl Is TextBox Or TypeOf ctl
Is
ComboBox Or _
TypeOf ctl Is ListBox Or TypeOf ctl Is CheckBox Then
If Left(ctl.ControlSource, 1) <"=" Then
ctl.Value = Null
End If
End If
Next

Exit_BTN_Clear_All_Click:
Exit Sub

Err_BTN_Clear_All_Click:
MsgBox Err.Description
Resume Exit_BTN_Clear_All_Click

End Sub

In the form module we would have a call to

ClearForm Me

BUT ... what are you trying to do here? ... it looks to me like "plans
for levitation upon painting oneself into a corner".

Dec 14 '07 #2

P: n/a
Thanks, Lyle!

With one minor tweak (calling Clear_All Me) your mod works dandy.

What I am doing is giving the operator a button to clear all of the
fields on a data entry form EXCEPT a few fields I don't want touched.

Works like a charm.

Patrick

On Dec 14, 12:26 pm, lyle <lyle.fairfi...@gmail.comwrote:
Public Sub Clear_All(ByRef CallingForm as Form)
On Error GoTo Err_BTN_Clear_All_Click

Dim ctl As Control
For Each ctl In CallingForm.Controls
If ctl.Tag <"NoDel" And TypeOf ctl Is TextBox Or TypeOf ctl
Is
ComboBox Or _
TypeOf ctl Is ListBox Or TypeOf ctl Is CheckBox Then
If Left(ctl.ControlSource, 1) <"=" Then
ctl.Value = Null
End If
End If
Next

Exit_BTN_Clear_All_Click:
Exit Sub

Err_BTN_Clear_All_Click:
MsgBox Err.Description
Resume Exit_BTN_Clear_All_Click

End Sub

In the form module we would have a call to

ClearForm Me

BUT ... what are you trying to do here? ... it looks to me like "plans
for levitation upon painting oneself into a corner".
Dec 14 '07 #3

P: n/a
Patrick A <pa*****@stradley.comwrote:
If ctl.Tag <"NoDel"
I'd be tempted to use an InStr function there in case you should ever decide you need
to have two tags for some controls. Highly unlikely and I've never done it yet.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
Dec 14 '07 #4

P: n/a
"Tony Toews [MVP]" <tt****@telusplanet.netwrote in
news:vo********************************@4ax.com:
Patrick A <pa*****@stradley.comwrote:
> If ctl.Tag <"NoDel"

I'd be tempted to use an InStr function there in case you should
ever decide you need to have two tags for some controls. Highly
unlikely and I've never done it yet.
I think it's a bad idea to overload the .Tag property with multiple
values, kind of like denormalization. That said, the ADH has
included code for doing just that for as long as I've been using it.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Dec 14 '07 #5

P: n/a
"David W. Fenton" <XX*******@dfenton.com.invalidwrote:
>> If ctl.Tag <"NoDel"

I'd be tempted to use an InStr function there in case you should
ever decide you need to have two tags for some controls. Highly
unlikely and I've never done it yet.

I think it's a bad idea to overload the .Tag property with multiple
values, kind of like denormalization.
<shrug But what else are you going to do if you ever need to?
>That said, the ADH has
included code for doing just that for as long as I've been using it.
I used to look in those books a lot but haven't these last few years. I should crack
them open again.

Tny

--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
Dec 15 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.