Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Clear Form

Geek News

Clear Form
"JezLisle via AccessMonster.com" <u43150[ at ]uwe> 11/13/2008 3:50:21 PM
I am using this code at the end of my routine that once all data has been
updated in the table it then clears all values from the TextBox's or Combo's
on the form.

My problem is that I keep getting this error message on the following code
and dont know why or how to get around it

Me.PersonalID.Value = ""
Me.txtForename.Value = ""
Me.txtSurname.Value = ""
Me.txtAddress1.Value = ""

Error: "You tried to assign the NULL value to a variable that is not a
Variant data type"

What would this appear for, as all I was trying to do is clear any values in
TextBox's or Combo's on the form?

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200811/1

Re: Clear Form
"Allen Browne" <AllenBrowne[ at ]SeeSig.Invalid> 11/13/2008 3:56:59 PM
If this form is bound to a table or query, perhaps you could just move it to
a new record with:
If Me.Dirty Then Me.Dirty = False
RunCommand acCmdRecordsGotoNew

If you don't want to save the record, perhaps you could undo the current
edits:
Me.Undo

If it is unbound, it would probably be better to assign Null rather than a
zero-length string, e.g.:
Me.PersonalID = Null

If you are still stuck, comment out all lines but one, and see if the error
occurs. Repeat with different lines in, until you pin down the problem one.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"JezLisle via AccessMonster.com" <u43150[ at ]uwe> wrote in message
news:8d221bad235fd[ at ]uwe...
[Quoted Text]
>I am using this code at the end of my routine that once all data has been
> updated in the table it then clears all values from the TextBox's or
> Combo's
> on the form.
>
> My problem is that I keep getting this error message on the following code
> and dont know why or how to get around it
>
> Me.PersonalID.Value = ""
> Me.txtForename.Value = ""
> Me.txtSurname.Value = ""
> Me.txtAddress1.Value = ""
>
> Error: "You tried to assign the NULL value to a variable that is not a
> Variant data type"
>
> What would this appear for, as all I was trying to do is clear any values
> in
> TextBox's or Combo's on the form?
>
> --
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200811/1
>

Re: Clear Form
"JezLisle via AccessMonster.com" <u43150[ at ]uwe> 11/14/2008 11:02:36 AM
Thanks,

I have a form which is bound apart from the PatientNo which I input via an
input box.

does that make a difference?

The Me.TextBox = "" seems to work fine, it is just the PatientNo TextBox
which is unbound, how can I clear this to then input a new number?


Allen Browne wrote:
[Quoted Text]
>If this form is bound to a table or query, perhaps you could just move it to
>a new record with:
> If Me.Dirty Then Me.Dirty = False
> RunCommand acCmdRecordsGotoNew
>
>If you don't want to save the record, perhaps you could undo the current
>edits:
> Me.Undo
>
>If it is unbound, it would probably be better to assign Null rather than a
>zero-length string, e.g.:
> Me.PersonalID = Null
>
>If you are still stuck, comment out all lines but one, and see if the error
>occurs. Repeat with different lines in, until you pin down the problem one.
>
>>I am using this code at the end of my routine that once all data has been
>> updated in the table it then clears all values from the TextBox's or
>[quoted text clipped - 15 lines]
>> in
>> TextBox's or Combo's on the form?

--
Message posted via http://www.accessmonster.com

Re: Clear Form
"Allen Browne" <AllenBrowne[ at ]SeeSig.Invalid> 11/14/2008 1:01:39 PM
After the suggested RunCommand line, add:
Me.PersonalID = Null

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"JezLisle via AccessMonster.com" <u43150[ at ]uwe> wrote in message
news:8d2c2b7274eb0[ at ]uwe...
[Quoted Text]
> Thanks,
>
> I have a form which is bound apart from the PatientNo which I input via an
> input box.
>
> does that make a difference?
>
> The Me.TextBox = "" seems to work fine, it is just the PatientNo TextBox
> which is unbound, how can I clear this to then input a new number?
>
>
> Allen Browne wrote:
>>If this form is bound to a table or query, perhaps you could just move it
>>to
>>a new record with:
>> If Me.Dirty Then Me.Dirty = False
>> RunCommand acCmdRecordsGotoNew
>>
>>If you don't want to save the record, perhaps you could undo the current
>>edits:
>> Me.Undo
>>
>>If it is unbound, it would probably be better to assign Null rather than a
>>zero-length string, e.g.:
>> Me.PersonalID = Null
>>
>>If you are still stuck, comment out all lines but one, and see if the
>>error
>>occurs. Repeat with different lines in, until you pin down the problem
>>one.
>>
>>>I am using this code at the end of my routine that once all data has been
>>> updated in the table it then clears all values from the TextBox's or
>>[quoted text clipped - 15 lines]
>>> in
>>> TextBox's or Combo's on the form?

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net