Conditional code Problem on form

I

Isis

When new form is filled out the first field is [JTNUMBER] - when this has
been filled in I want to autofill the values in several other controls -
the JTNUMBER field is a Number - the other fields I want to fill are
Strings - this is my code;

Private Sub JTNumber_Change()
If [Pic1] = "" Then
[Pic1] = [JTNumber] & "a" & ".jpg"
[Pic2] = [JTNumber] & "b" & ".jpg"
[Pic3] = [JTNumber] & "c" & ".jpg"
[Pic4] = [JTNumber] & "d" & ".jpg"
Other Stuff etc

This does not seem to work - IE nothing appears in my Pic1 - Pic5 fields
- There is nothing in the Pic1 field on a new form.

What am I doing wrong - is there a better way of approaching this problem
?


Thanks
 
W

Wayne Morgan

First, I would probably use JTNumber's AfterUpdate event instead of the
Change event. Using the Change event will cause this to be run each time you
type a character into the textbox. So, after the first character is typed,
[Pic1] will no longer be ="". The AfterUpdate event will run when you are
done and press enter or tab out of the control.

The next question is whether Pic1 = "" or Pic1 is null. Try this instead:

If Nz([Pic1], "") = "" Then

This will work if the value is Null or "".
 
I

Isis

First, I would probably use JTNumber's AfterUpdate event instead of
the Change event. Using the Change event will cause this to be run
each time you type a character into the textbox. So, after the first
character is typed, [Pic1] will no longer be ="". The AfterUpdate
event will run when you are done and press enter or tab out of the
control.

The next question is whether Pic1 = "" or Pic1 is null. Try this
instead:

If Nz([Pic1], "") = "" Then

This will work if the value is Null or "".

Thanks very much for that Wayne - it is very helpful.

Regards
 

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