apending data to table from unbound form when form field blank

G

Guest

Does anyone know a function or method to apend data from an unbound form to a
table when the form textbox is blank?
Dealing with only text fields in my table, am using code:

""" & Me![formfield1] & """

When the form field is blank it creates code "". (two double quotes side by
side)
The access table does not like this. (the
field property "required"
is set to no)

I was hoping to avoid the looping through all the textbox controls on my
form, seeing if it has a value then getting the name and value of the textbox
and building an sql statment.
 
G

Guest

What you are experiencing is a good argument for not using unbound controls.
(I love pain and I want to make my life harder!)

IIf(IsNull(Me![formfield1]), Null, """ & Me![formfield1] & """)
 
G

Guest

Yes that worked, I had to modify it a little:
from:
IIf(IsNull(Me![formfield1]), Null, Me![formfield1] & """)
to:
IIf(IsNull(Me![formfield1]), Null, Me![formfield1 & """ , """)

just before the IIf is: """ & Me![formfieldKEY] & """ , """ &

also in the
INSERT INTO [tablename] (Key, " & IIf(IsNull(Me![formfield1]), Null,
"formfield1,") & "" & IIf(IsNull . . . continue with more IIf statements

my table field names and form textbox control names are the same.
 

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