INSERT INTO Table, values derived in code from separating a name

B

Billp

Hi,

I have a field called [Contact Name] which is the result of a combo box.
On not in list the user is asked if the name they enter is too be added to
the list.

The name is separated into two strings "str1l" and "str2" in code form a
module as the function is called up from the not in List on the Combo box.

str1 is FIRST_NAME
str2 is LAST_NAME

The fields in tblCUSTCONTACTS are "FIRST_NAME" and "LAST_NAME"

Now I wish to INSERT into the tblCUSTCONTACTS the two strings.

strsql = "INSERT INTO [tblCUSTCONTACTS] " _
& "(FIRST_NAME),(LAST_NAME) " _
& "SELECT str1,str2 FROM ????????????????????????? " _
& "WHERE [CustID] = " & Forms![Sales Enquiry Register
edit form]![CustID]

How do I reference the str1 and str2 that I have in code?

CustID is the reference from the form.
tblCUSTCONTACTS hasa unique Identoifing autonumber feild called "ID" for
each entry which creates a record which Firstname and Lastname will be one
record

Thanks.
 
B

Benjamins via AccessMonster.com

Hi Billp,

Since you has already split up the name into str1 and str2, you can just
insert the value in.
strsql = "INSERT INTO [tblCUSTCONTACTS] (FIRST_NAME, LAST_NAME) " & _
"VALUES('" & str1 & "', '" & str2 & "')"

You need not need to use the SELECT statement. SELECT statement is more
suitable if there is multi records to insert.
Hi,

I have a field called [Contact Name] which is the result of a combo box.
On not in list the user is asked if the name they enter is too be added to
the list.

The name is separated into two strings "str1l" and "str2" in code form a
module as the function is called up from the not in List on the Combo box.

str1 is FIRST_NAME
str2 is LAST_NAME

The fields in tblCUSTCONTACTS are "FIRST_NAME" and "LAST_NAME"

Now I wish to INSERT into the tblCUSTCONTACTS the two strings.

strsql = "INSERT INTO [tblCUSTCONTACTS] " _
& "(FIRST_NAME),(LAST_NAME) " _
& "SELECT str1,str2 FROM ????????????????????????? " _
& "WHERE [CustID] = " & Forms![Sales Enquiry Register
edit form]![CustID]

How do I reference the str1 and str2 that I have in code?

CustID is the reference from the form.
tblCUSTCONTACTS hasa unique Identoifing autonumber feild called "ID" for
each entry which creates a record which Firstname and Lastname will be one
record

Thanks.
 

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