Thanks so much for your help, I made the adjustments you suggested and the
code works; however, I do still have a problem. The combo box is on
a form which also has a sub form connected in a one to many relationship.
I need to amend the code so when I add the values to the main form through
the combo box, a new blank record is prepared and ready to recieve infomation
for the sub form. The subForm is called Colors has two fields, an
autoIdNumber and Color. Right now when I run the code, I get an error message
"Your changes were not sucessful because they would create duplicate
values...etc. I believe that what is happening is a new autonumber is not
being created on the subform (as it needs to be) so there is a duplicate
value, a violation and I can not create the new record.
Any help is greatly appreciated.
Lele
"Terry Kreft" wrote:
> The faults with your string are;-
> There is a mising space after the ) on the first line
> the quotes in the second line are wrong
>
> Assuming PatternName an Manufacturer are both Text fields you should be
> using
>
> sqlAddPattern = "INSERT INTO Patterns (PatternName,Manufacturer) " & _
> "VALUES (""" & NewData & """,""" & Me.Manufacturer & """)"
>
> Notice how for each " we want embedded in the string ther are actually a
> pair of ".
>
> --
>
> Terry Kreft
>
>
> "Lele" <(E-Mail Removed)> wrote in message
> news:99049934-714C-476D-9774-(E-Mail Removed)...
> > Hello Again Ken,
> >
> > When I enter the code shown below I get the error message COMPILE ERROR:
> > EXPECTED END OF STATEMENT . When I click ok, the cursor jumps to the
> "",""
> > and the entire line is then shown in the color red.
> >
> > sqlAddPattern = "INSERT INTO Patterns (PatternName,Manufacturer)" & _
> > "VALUES (""" & NewData & "","" & Me.Manufacturer & "")"
> >
> > What am I doing wrong?
> >
> > Thanks again.
> > --
> > Lele
> >
> >
> > "Ken Sheridan" wrote:
> >
> > > Lele:
> > >
> > > Mea culpa! The opening quote character is missing from the second line:
> > >
> > > sqlAddPattern = "INSERT INTO Patterns (PatternName, Manufacturer) " & _
> > > "VALUES (""" & NewData & "","" & Me.Manufacturer & "")"
> > >
> > > This is entered as two lines but is executed as one, so it builds a
> single
> > > string expression which is assigned to the sqlAddPattern variable. You
> are
> > > quite right about the underscore character at the end of the first line
> being
> > > a continuation character, which is used to make code more readable by
> > > avoiding individual lines being too long and requiring you to scroll
> right to
> > > see the end of the line. If I entered it all as one line here it would
> wrap
> > > within the message window of course, likes so:
> > >
> > > sqlAddPattern = "INSERT INTO Patterns (PatternName, Manufacturer)
> VALUES
> > > (""" & NewData & "","" & Me.Manufacturer & "")"
> > >
> > > but that doesn't happen in the VBA window.
> > >
> > > Sorry about the confusion.
> > >
> > > Ken Sheridan
> > > Staffprd, England
> > >
> > > "Lele" wrote:
> > >
> > > > Thanks so much for your help. i believe I am very close on this. The
> line
> > > >
> > > > sqlAddPattern = "INSERT INTO Patterns (PatternName, Manufacturer) "
> > > > & _
> > > > VALUES (""" & NewData & "","" & Me.Manufacturer & "")"
> > > >
> > > > Is causing me a bit of confusion. I think the &_ is just a way of
> > > > continuing the same line and is unnecessary to type. Is that correct?
> Also
> > > > when I type the " before the word VALUES I get the error: expected end
> of
> > > > statement. When I eliminate it and type the rest of the code, I get
> the
> > > > runtime error message, Unable to find your field "|"
> > > >
> > > > Thanks again
> > > >
> > > > --
> > > > Lele
> > > >
> > > >
> > >
>
>
>
|