copy data to new record

  • Thread starter Thread starter Karen Skipper
  • Start date Start date
K

Karen Skipper

I've been working on this code and now get an error saying " invalid use of
null". How do I handle null fields (they are okay in what I'm doing)?
Sample of code below:

'save data in fields
emailvar = Me!
extvar = Me![EXTENTION]
phonevar = Me![PHONE]
faxvar = Me![FAX]
origvar = Me![originator]

'code in here to append a new record to the table

'copy data in fields
Me![EMAIL] = emailvar
Me![EXTENTION] = extvar
Me![PHONE] = phonevar
Me![FAX] = faxvar
Me![originator] = origvar


Any help?

Karen
 
If you dimmed your variables as string you may need to dim them as variant.
Variant can handle null but a string type can't.

hth
--
-Larry-
--

Karen Skipper said:
I've been working on this code and now get an error saying " invalid use of
null". How do I handle null fields (they are okay in what I'm doing)?
Sample of code below:

'save data in fields
emailvar = Me!(e-mail address removed)
 
Thanks, That seems to fix the problem.

FYI-
I also found that I have to have the docmd.Echo true (there is a docmd.echo
false at the beginning of the code) after the section that fills in the new
fields or some of them appear to be empty until I move to the previous
record and back to the new one. I had it in the section where the new
record is appended. I'm not sure that even helps keep the user from seeing
the form change and the fields get filled in.

Karen


Larry Daugherty said:
If you dimmed your variables as string you may need to dim them as variant.
Variant can handle null but a string type can't.

hth
--
-Larry-
--

Karen Skipper said:
I've been working on this code and now get an error saying " invalid use of
null". How do I handle null fields (they are okay in what I'm doing)?
Sample of code below:

'save data in fields
emailvar = Me!(e-mail address removed)
 
Back
Top