Alternate input masks on a form

R

Robin Chapple

I have a membership database with one [PhoneBH] as one of the fields.
I have an input mask to ensure uniformity of presentation when
printed.

Recently members are using a mobile phone as their business contact
number. I would like to present an option button:

" Business number is a mobile "

which changes the default mask.

Default mask is:

00\ 0000\ 0000;0

and mobile mask is:

0000\ 000\ 000;0

Is this possible?

Thanks,

Robin Chapple
 
D

Douglas J. Steele

You can dynamically alter the InputMask property.

Me!MyTextBox.InputMask = "00\ 0000\ 0000;0"

or

Me!MyTextBox.InputMask = "0000\ 000\ 000;0"

in the AfterUpdate property of your option button.
 
R

Robin Chapple

In case it is important the full message is:

"Runtime error:

Object does not support this property or method ""

Robin
 
J

J. Goddard

It should support it. Can you post the code that (attempts to) changes
the mask property?

John
 
R

Robin Chapple

Thanks John,

Private Sub Form_Current()

Me.LastName.SetFocus

If Me.NewRecord Then
Me!fMobileBHSub.Form![MobileBH].Visible = True
ElseIf Len([PhoneBH] & "") = 0 Then
Me!fMobileBHSub.Form![MobileBH].Visible = True
Else
Me!fMobileBHSub.SetFocus
Me!fMobileBHSub.Form![MemberID].SetFocus
Me!fMobileBHSub.Form![MobileBH].Visible = False
End If

If Not IsNull(Me!fMobileBHSub.Form![MobileBH]) Then
Me.[PhoneBH].Visible = False
End If

End Sub

Cheers,

Robin
 
J

J. Goddard

Um, I don't see anything in that code that changes an input mask - am I
missing something?

Are you able to determine which line is causing the error?

John


Robin said:
Thanks John,

Private Sub Form_Current()

Me.LastName.SetFocus

If Me.NewRecord Then
Me!fMobileBHSub.Form![MobileBH].Visible = True
ElseIf Len([PhoneBH] & "") = 0 Then
Me!fMobileBHSub.Form![MobileBH].Visible = True
Else
Me!fMobileBHSub.SetFocus
Me!fMobileBHSub.Form![MemberID].SetFocus
Me!fMobileBHSub.Form![MobileBH].Visible = False
End If

If Not IsNull(Me!fMobileBHSub.Form![MobileBH]) Then
Me.[PhoneBH].Visible = False
End If

End Sub

Cheers,

Robin


It should support it. Can you post the code that (attempts to) changes
the mask property?

John


Robin Chapple wrote:
 
R

Robin Chapple

John,

I was missing putting my brain into gear. My apology.

Here is the code behind the option button:

Private Sub BHMobile_AfterUpdate()

Me!PhoneBH.InputMask = "0000\ 000\ 000;0"

End Sub

Thanks,

Robin


Um, I don't see anything in that code that changes an input mask - am I
missing something?

Are you able to determine which line is causing the error?

John


Robin said:
Thanks John,

Private Sub Form_Current()

Me.LastName.SetFocus

If Me.NewRecord Then
Me!fMobileBHSub.Form![MobileBH].Visible = True
ElseIf Len([PhoneBH] & "") = 0 Then
Me!fMobileBHSub.Form![MobileBH].Visible = True
Else
Me!fMobileBHSub.SetFocus
Me!fMobileBHSub.Form![MemberID].SetFocus
Me!fMobileBHSub.Form![MobileBH].Visible = False
End If

If Not IsNull(Me!fMobileBHSub.Form![MobileBH]) Then
Me.[PhoneBH].Visible = False
End If

End Sub

Cheers,

Robin


It should support it. Can you post the code that (attempts to) changes
the mask property?

John


Robin Chapple wrote:


In case it is important the full message is:

"Runtime error:

Object does not support this property or method ""

Robin

On Sun, 10 Sep 2006 10:27:27 +1000, Robin Chapple



Thanks Doug,

Error message says:

"Not supported"

Robin

On Sat, 9 Sep 2006 17:24:54 -0400, "Douglas J. Steele"



You can dynamically alter the InputMask property.

Me!MyTextBox.InputMask = "00\ 0000\ 0000;0"

or

Me!MyTextBox.InputMask = "0000\ 000\ 000;0"

in the AfterUpdate property of your option button.
 
J

J. Goddard

Hi -

The only thing I can think of is that [PhoneBH] is not a text box. If
it IS a textbox, then I don't know - the code looks fine.
Is [PhoneBH] visible when you execute the code?

Anyone?

It's going to be something obvious, of course!

John


Robin said:
John,

I was missing putting my brain into gear. My apology.

Here is the code behind the option button:

Private Sub BHMobile_AfterUpdate()

Me!PhoneBH.InputMask = "0000\ 000\ 000;0"

End Sub

Thanks,

Robin


Um, I don't see anything in that code that changes an input mask - am I
missing something?

Are you able to determine which line is causing the error?

John


Robin Chapple wrote:

Thanks John,

Private Sub Form_Current()

Me.LastName.SetFocus

If Me.NewRecord Then
Me!fMobileBHSub.Form![MobileBH].Visible = True
ElseIf Len([PhoneBH] & "") = 0 Then
Me!fMobileBHSub.Form![MobileBH].Visible = True
Else
Me!fMobileBHSub.SetFocus
Me!fMobileBHSub.Form![MemberID].SetFocus
Me!fMobileBHSub.Form![MobileBH].Visible = False
End If

If Not IsNull(Me!fMobileBHSub.Form![MobileBH]) Then
Me.[PhoneBH].Visible = False
End If

End Sub

Cheers,

Robin


On Sat, 09 Sep 2006 21:19:40 -0400, "J. Goddard"



It should support it. Can you post the code that (attempts to) changes
the mask property?

John


Robin Chapple wrote:



In case it is important the full message is:

"Runtime error:

Object does not support this property or method ""

Robin

On Sun, 10 Sep 2006 10:27:27 +1000, Robin Chapple




Thanks Doug,

Error message says:

"Not supported"

Robin

On Sat, 9 Sep 2006 17:24:54 -0400, "Douglas J. Steele"




You can dynamically alter the InputMask property.

Me!MyTextBox.InputMask = "00\ 0000\ 0000;0"

or

Me!MyTextBox.InputMask = "0000\ 000\ 000;0"

in the AfterUpdate property of your option button.
 
R

Robin Chapple

G'day,

[PhoneBH] is a text box and it is visible,

Robin

Hi -

The only thing I can think of is that [PhoneBH] is not a text box. If
it IS a textbox, then I don't know - the code looks fine.
Is [PhoneBH] visible when you execute the code?

Anyone?

It's going to be something obvious, of course!

John


Robin said:
John,

I was missing putting my brain into gear. My apology.

Here is the code behind the option button:

Private Sub BHMobile_AfterUpdate()

Me!PhoneBH.InputMask = "0000\ 000\ 000;0"

End Sub

Thanks,

Robin


Um, I don't see anything in that code that changes an input mask - am I
missing something?

Are you able to determine which line is causing the error?

John


Robin Chapple wrote:


Thanks John,

Private Sub Form_Current()

Me.LastName.SetFocus

If Me.NewRecord Then
Me!fMobileBHSub.Form![MobileBH].Visible = True
ElseIf Len([PhoneBH] & "") = 0 Then
Me!fMobileBHSub.Form![MobileBH].Visible = True
Else
Me!fMobileBHSub.SetFocus
Me!fMobileBHSub.Form![MemberID].SetFocus
Me!fMobileBHSub.Form![MobileBH].Visible = False
End If

If Not IsNull(Me!fMobileBHSub.Form![MobileBH]) Then
Me.[PhoneBH].Visible = False
End If

End Sub

Cheers,

Robin


On Sat, 09 Sep 2006 21:19:40 -0400, "J. Goddard"



It should support it. Can you post the code that (attempts to) changes
the mask property?

John


Robin Chapple wrote:



In case it is important the full message is:

"Runtime error:

Object does not support this property or method ""

Robin

On Sun, 10 Sep 2006 10:27:27 +1000, Robin Chapple




Thanks Doug,

Error message says:

"Not supported"

Robin

On Sat, 9 Sep 2006 17:24:54 -0400, "Douglas J. Steele"




You can dynamically alter the InputMask property.

Me!MyTextBox.InputMask = "00\ 0000\ 0000;0"

or

Me!MyTextBox.InputMask = "0000\ 000\ 000;0"

in the AfterUpdate property of your option button.
 
J

J. Goddard

Hi -

Well, unfortunately I don't know where else to look. I don't see
anything wrong.

I just noticed - you have a logic error in the code -

[Phonebh] will always have the same mask, regardless of what the user's
do - you have to check whether BHMobile is true or not and set the mask
accordingly.

If BHmobile then
Me!PhoneBH.InputMask = "0000\ 000\ 000;0"
else
Me!PhoneBH.InputMask = ....
endif

John




Robin said:
G'day,

[PhoneBH] is a text box and it is visible,

Robin

Hi -

The only thing I can think of is that [PhoneBH] is not a text box. If
it IS a textbox, then I don't know - the code looks fine.
Is [PhoneBH] visible when you execute the code?

Anyone?

It's going to be something obvious, of course!

John


Robin Chapple wrote:

John,

I was missing putting my brain into gear. My apology.

Here is the code behind the option button:

Private Sub BHMobile_AfterUpdate()

Me!PhoneBH.InputMask = "0000\ 000\ 000;0"

End Sub

Thanks,

Robin


On Tue, 12 Sep 2006 20:56:49 -0400, "J. Goddard"



Um, I don't see anything in that code that changes an input mask - am I
missing something?

Are you able to determine which line is causing the error?

John


Robin Chapple wrote:



Thanks John,

Private Sub Form_Current()

Me.LastName.SetFocus

If Me.NewRecord Then
Me!fMobileBHSub.Form![MobileBH].Visible = True
ElseIf Len([PhoneBH] & "") = 0 Then
Me!fMobileBHSub.Form![MobileBH].Visible = True
Else
Me!fMobileBHSub.SetFocus
Me!fMobileBHSub.Form![MemberID].SetFocus
Me!fMobileBHSub.Form![MobileBH].Visible = False
End If

If Not IsNull(Me!fMobileBHSub.Form![MobileBH]) Then
Me.[PhoneBH].Visible = False
End If

End Sub

Cheers,

Robin


On Sat, 09 Sep 2006 21:19:40 -0400, "J. Goddard"




It should support it. Can you post the code that (attempts to) changes
the mask property?

John


Robin Chapple wrote:




In case it is important the full message is:

"Runtime error:

Object does not support this property or method ""

Robin

On Sun, 10 Sep 2006 10:27:27 +1000, Robin Chapple





Thanks Doug,

Error message says:

"Not supported"

Robin

On Sat, 9 Sep 2006 17:24:54 -0400, "Douglas J. Steele"





You can dynamically alter the InputMask property.

Me!MyTextBox.InputMask = "00\ 0000\ 0000;0"

or

Me!MyTextBox.InputMask = "0000\ 000\ 000;0"

in the AfterUpdate property of your option button.
 
D

Douglas J. Steele

You need to ensure that's what put in the InputMask has quotes around it:

If BHmobile then
Me!PhoneBH.InputMask = """0000\ 000\ 000;0"""
else
Me!PhoneBH.InputMask = ....
endif

or

If BHmobile then
Me!PhoneBH.InputMask = Chr$(34) & "0000\ 000\ 000;0" & Chr$(34)
else
Me!PhoneBH.InputMask = ....
endif


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


J. Goddard said:
Hi -

Well, unfortunately I don't know where else to look. I don't see anything
wrong.

I just noticed - you have a logic error in the code -

[Phonebh] will always have the same mask, regardless of what the user's
do - you have to check whether BHMobile is true or not and set the mask
accordingly.

If BHmobile then
Me!PhoneBH.InputMask = "0000\ 000\ 000;0"
else
Me!PhoneBH.InputMask = ....
endif

John




Robin said:
G'day,

[PhoneBH] is a text box and it is visible,

Robin

Hi -

The only thing I can think of is that [PhoneBH] is not a text box. If it
IS a textbox, then I don't know - the code looks fine.
Is [PhoneBH] visible when you execute the code?

Anyone?

It's going to be something obvious, of course!

John


Robin Chapple wrote:


John,

I was missing putting my brain into gear. My apology.

Here is the code behind the option button:

Private Sub BHMobile_AfterUpdate()

Me!PhoneBH.InputMask = "0000\ 000\ 000;0"

End Sub

Thanks,

Robin


On Tue, 12 Sep 2006 20:56:49 -0400, "J. Goddard"



Um, I don't see anything in that code that changes an input mask - am I
missing something?

Are you able to determine which line is causing the error?

John


Robin Chapple wrote:



Thanks John,

Private Sub Form_Current()

Me.LastName.SetFocus

If Me.NewRecord Then
Me!fMobileBHSub.Form![MobileBH].Visible = True
ElseIf Len([PhoneBH] & "") = 0 Then
Me!fMobileBHSub.Form![MobileBH].Visible = True
Else
Me!fMobileBHSub.SetFocus
Me!fMobileBHSub.Form![MemberID].SetFocus
Me!fMobileBHSub.Form![MobileBH].Visible = False
End If
If Not IsNull(Me!fMobileBHSub.Form![MobileBH]) Then
Me.[PhoneBH].Visible = False
End If

End Sub

Cheers,

Robin


On Sat, 09 Sep 2006 21:19:40 -0400, "J. Goddard"




It should support it. Can you post the code that (attempts to)
changes the mask property?

John


Robin Chapple wrote:




In case it is important the full message is:

"Runtime error:

Object does not support this property or method ""

Robin

On Sun, 10 Sep 2006 10:27:27 +1000, Robin Chapple





Thanks Doug,

Error message says:

"Not supported"

Robin

On Sat, 9 Sep 2006 17:24:54 -0400, "Douglas J. Steele"





You can dynamically alter the InputMask property.

Me!MyTextBox.InputMask = "00\ 0000\ 0000;0"

or

Me!MyTextBox.InputMask = "0000\ 000\ 000;0"

in the AfterUpdate property of your option button.
 
R

Robin Chapple

The complete code now looks like this:

Private Sub BHMobile_AfterUpdate()

If BHMobile Then
Me!PhoneBH.InputMask = Chr$(34) & "0000\ 000\ 000;0" & Chr$(34)
Else
Me!PhoneBH.InputMask = Chr$(34) & "00\ 0000\ 0000;0" & Chr$(34)
End If

End Sub

I have tried it with and without a mask in the field properties and
both give the same error message.

Error 436 - Not supported.

Thanks,

Robin
 
J

J. Goddard

Clutching at straws a bit here -

Leave the After Update sub there, but comment out all the if-then-else
code, so really all you have is the 2 lines Sub... and End Sub. Does
the error go away? I'm thinking the error may not be coming from where
we think it is (unless you know from using the debug that it's here)

John
 
D

Douglas J. Steele

I'm guessing that your text box control and the field in the underlying
recordset are both named BHMobile. Try renaming the text box to, say,
txtBHMobile, which means that the event will be Private Sub
txtBHMobile_AfterUpdate().
 

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