PC Review


Reply
Thread Tools Rate Thread

Adding New Values to a combo box on the fly

 
 
=?Utf-8?B?TGVsZQ==?=
Guest
Posts: n/a
 
      9th Sep 2006
I am trying to add values to my combo box called Patterns on the fly. My
problem is the table of Patterns I am adding to requires both a PatternName
and a Manufacturer as primary fields for each record.

I have been using the code below supplied by Al Campagna.

Private Sub PatternName_NotInList(NewData As String, Response As Integer)
Dim sqlAddPattern As String, UserResponse As Integer
Beep
UserResponse = MsgBox("Do you want to add this Pattern to the list?", vbYesNo)
If UserResponse = vbYes Then
sqlAddPattern = "Insert Into Patterns ([PatternName]) values ('" &
NewData & "')"
CurrentDb.Execute sqlAddPattern, dbFailOnError
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If

End Sub

My first field on the form is manufacturer. Its drop down list is fairly
complete, and if not the above code works to add a new manufacturer to the
manufacturers table. Next I tab to the PatternName ComboBox. I get to the
point where it is ready to add the new name to the list, but if I try to
proceed I get a run time error 3058 primary or index field can not contain a
null value. The code line: CurrentDb.Execute sqlAddPattern, dbFailOnError is
highlighted

How can I modify the code so the manufacturer value i selected is also added
by the code?

Thanks so much

--
Lele
 
Reply With Quote
 
 
 
 
=?Utf-8?B?S2VuIFNoZXJpZGFu?=
Guest
Posts: n/a
 
      9th Sep 2006
Lele:

You'll need to insert values into both the PatternName and Manufacturer
fields in the Patterns table. You can get the latter from the Manufacturer
control in the form, and then concatenate it into the string expression for
the SQL statement. You should also first test for the manufacturer control
not being Null:

Private Sub PatternName_NotInList(NewData As String, Response As Integer)

Dim sqlAddPattern As String, strMessage As String
Dim UserResponse As Integer
Dim ctrl as Control

On Error Goto Err_Handler

Set ctrl = Me.ActiveControl

Beep
strMessage = "Do you want to add this Pattern to the list?"
UserResponse = MsgBox(strMessage, vbYesNo+ vbQuestion, "New Pattern")

If UserResponse = vbYes Then Then
If Not IsNull(Me.Manufacturer) then
sqlAddPattern = "INSERT INTO Patterns (PatternName, Manufacturer) "
& _
VALUES (""" & NewData & "","" & Me.Manufacturer & "")"
CurrentDb.Execute sqlAddPattern, dbFailOnError
Response = acDataErrAdded
Else
strMessage = "A manufacturer must be selected first."
MsgBox strMessage, vbExclamation, "Invalid Operation"
Response = acDataErrContinue
ctrl.Undo
End If
Else
Response = acDataErrContinue
ctrl.Undo
End If

Exit_Here:
Exit Sub

Err_Handler:
Response = acDataErrContinue
strMessage = Err.Description & " (" & Err.Number & ")"
MsgBox strMessage, vbExclamation, "Error"
Resume Exit_Here

End Sub

I'm assuming Manufacturer is a text field both in the form's underlying
table and in the Patterns table. Note that I've used doubled quotes
characters "" rather than a single quote character ' to represent a literal
quotes character within the string expressions. This guards against the
possibility of a patter or manufacturer's name containing one or more
apostrophes e.g. O'Reilly's Fabrics for the manufacturer or Witches' Brew
for the pattern.

Ken Sheridan
Stafford, England

"Lele" wrote:

> I am trying to add values to my combo box called Patterns on the fly. My
> problem is the table of Patterns I am adding to requires both a PatternName
> and a Manufacturer as primary fields for each record.
>
> I have been using the code below supplied by Al Campagna.
>
> Private Sub PatternName_NotInList(NewData As String, Response As Integer)
> Dim sqlAddPattern As String, UserResponse As Integer
> Beep
> UserResponse = MsgBox("Do you want to add this Pattern to the list?", vbYesNo)
> If UserResponse = vbYes Then
> sqlAddPattern = "Insert Into Patterns ([PatternName]) values ('" &
> NewData & "')"
> CurrentDb.Execute sqlAddPattern, dbFailOnError
> Response = acDataErrAdded
> Else
> Response = acDataErrContinue
> End If
>
> End Sub
>
> My first field on the form is manufacturer. Its drop down list is fairly
> complete, and if not the above code works to add a new manufacturer to the
> manufacturers table. Next I tab to the PatternName ComboBox. I get to the
> point where it is ready to add the new name to the list, but if I try to
> proceed I get a run time error 3058 primary or index field can not contain a
> null value. The code line: CurrentDb.Execute sqlAddPattern, dbFailOnError is
> highlighted
>
> How can I modify the code so the manufacturer value i selected is also added
> by the code?
>
> Thanks so much
>
> --
> Lele


 
Reply With Quote
 
=?Utf-8?B?TGVsZQ==?=
Guest
Posts: n/a
 
      10th Sep 2006
Hello Ken,
thanks so much for your help on this. I believe I am very close to making
this work. Unfortunately, I am getting so errors when I try to run the code.



--
Lele


"Ken Sheridan" wrote:

> Lele:
>
> You'll need to insert values into both the PatternName and Manufacturer
> fields in the Patterns table. You can get the latter from the Manufacturer
> control in the form, and then concatenate it into the string expression for
> the SQL statement. You should also first test for the manufacturer control
> not being Null:
>
> Private Sub PatternName_NotInList(NewData As String, Response As Integer)
>
> Dim sqlAddPattern As String, strMessage As String
> Dim UserResponse As Integer
> Dim ctrl as Control
>
> On Error Goto Err_Handler
>
> Set ctrl = Me.ActiveControl
>
> Beep
> strMessage = "Do you want to add this Pattern to the list?"
> UserResponse = MsgBox(strMessage, vbYesNo+ vbQuestion, "New Pattern")
>
> If UserResponse = vbYes Then Then
> If Not IsNull(Me.Manufacturer) then
> sqlAddPattern = "INSERT INTO Patterns (PatternName, Manufacturer) "
> & _
> VALUES (""" & NewData & "","" & Me.Manufacturer & "")"
> CurrentDb.Execute sqlAddPattern, dbFailOnError
> Response = acDataErrAdded
> Else
> strMessage = "A manufacturer must be selected first."
> MsgBox strMessage, vbExclamation, "Invalid Operation"
> Response = acDataErrContinue
> ctrl.Undo
> End If
> Else
> Response = acDataErrContinue
> ctrl.Undo
> End If
>
> Exit_Here:
> Exit Sub
>
> Err_Handler:
> Response = acDataErrContinue
> strMessage = Err.Description & " (" & Err.Number & ")"
> MsgBox strMessage, vbExclamation, "Error"
> Resume Exit_Here
>
> End Sub
>
> I'm assuming Manufacturer is a text field both in the form's underlying
> table and in the Patterns table. Note that I've used doubled quotes
> characters "" rather than a single quote character ' to represent a literal
> quotes character within the string expressions. This guards against the
> possibility of a patter or manufacturer's name containing one or more
> apostrophes e.g. O'Reilly's Fabrics for the manufacturer or Witches' Brew
> for the pattern.
>
> Ken Sheridan
> Stafford, England
>
> "Lele" wrote:
>
> > I am trying to add values to my combo box called Patterns on the fly. My
> > problem is the table of Patterns I am adding to requires both a PatternName
> > and a Manufacturer as primary fields for each record.
> >
> > I have been using the code below supplied by Al Campagna.
> >
> > Private Sub PatternName_NotInList(NewData As String, Response As Integer)
> > Dim sqlAddPattern As String, UserResponse As Integer
> > Beep
> > UserResponse = MsgBox("Do you want to add this Pattern to the list?", vbYesNo)
> > If UserResponse = vbYes Then
> > sqlAddPattern = "Insert Into Patterns ([PatternName]) values ('" &
> > NewData & "')"
> > CurrentDb.Execute sqlAddPattern, dbFailOnError
> > Response = acDataErrAdded
> > Else
> > Response = acDataErrContinue
> > End If
> >
> > End Sub
> >
> > My first field on the form is manufacturer. Its drop down list is fairly
> > complete, and if not the above code works to add a new manufacturer to the
> > manufacturers table. Next I tab to the PatternName ComboBox. I get to the
> > point where it is ready to add the new name to the list, but if I try to
> > proceed I get a run time error 3058 primary or index field can not contain a
> > null value. The code line: CurrentDb.Execute sqlAddPattern, dbFailOnError is
> > highlighted
> >
> > How can I modify the code so the manufacturer value i selected is also added
> > by the code?
> >
> > Thanks so much
> >
> > --
> > Lele

>

 
Reply With Quote
 
=?Utf-8?B?TGVsZQ==?=
Guest
Posts: n/a
 
      10th Sep 2006
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


"Ken Sheridan" wrote:

> Lele:
>
> You'll need to insert values into both the PatternName and Manufacturer
> fields in the Patterns table. You can get the latter from the Manufacturer
> control in the form, and then concatenate it into the string expression for
> the SQL statement. You should also first test for the manufacturer control
> not being Null:
>
> Private Sub PatternName_NotInList(NewData As String, Response As Integer)
>
> Dim sqlAddPattern As String, strMessage As String
> Dim UserResponse As Integer
> Dim ctrl as Control
>
> On Error Goto Err_Handler
>
> Set ctrl = Me.ActiveControl
>
> Beep
> strMessage = "Do you want to add this Pattern to the list?"
> UserResponse = MsgBox(strMessage, vbYesNo+ vbQuestion, "New Pattern")
>
> If UserResponse = vbYes Then Then
> If Not IsNull(Me.Manufacturer) then
> sqlAddPattern = "INSERT INTO Patterns (PatternName, Manufacturer) "
> & _
> VALUES (""" & NewData & "","" & Me.Manufacturer & "")"
> CurrentDb.Execute sqlAddPattern, dbFailOnError
> Response = acDataErrAdded
> Else
> strMessage = "A manufacturer must be selected first."
> MsgBox strMessage, vbExclamation, "Invalid Operation"
> Response = acDataErrContinue
> ctrl.Undo
> End If
> Else
> Response = acDataErrContinue
> ctrl.Undo
> End If
>
> Exit_Here:
> Exit Sub
>
> Err_Handler:
> Response = acDataErrContinue
> strMessage = Err.Description & " (" & Err.Number & ")"
> MsgBox strMessage, vbExclamation, "Error"
> Resume Exit_Here
>
> End Sub
>
> I'm assuming Manufacturer is a text field both in the form's underlying
> table and in the Patterns table. Note that I've used doubled quotes
> characters "" rather than a single quote character ' to represent a literal
> quotes character within the string expressions. This guards against the
> possibility of a patter or manufacturer's name containing one or more
> apostrophes e.g. O'Reilly's Fabrics for the manufacturer or Witches' Brew
> for the pattern.
>
> Ken Sheridan
> Stafford, England
>
> "Lele" wrote:
>
> > I am trying to add values to my combo box called Patterns on the fly. My
> > problem is the table of Patterns I am adding to requires both a PatternName
> > and a Manufacturer as primary fields for each record.
> >
> > I have been using the code below supplied by Al Campagna.
> >
> > Private Sub PatternName_NotInList(NewData As String, Response As Integer)
> > Dim sqlAddPattern As String, UserResponse As Integer
> > Beep
> > UserResponse = MsgBox("Do you want to add this Pattern to the list?", vbYesNo)
> > If UserResponse = vbYes Then
> > sqlAddPattern = "Insert Into Patterns ([PatternName]) values ('" &
> > NewData & "')"
> > CurrentDb.Execute sqlAddPattern, dbFailOnError
> > Response = acDataErrAdded
> > Else
> > Response = acDataErrContinue
> > End If
> >
> > End Sub
> >
> > My first field on the form is manufacturer. Its drop down list is fairly
> > complete, and if not the above code works to add a new manufacturer to the
> > manufacturers table. Next I tab to the PatternName ComboBox. I get to the
> > point where it is ready to add the new name to the list, but if I try to
> > proceed I get a run time error 3058 primary or index field can not contain a
> > null value. The code line: CurrentDb.Execute sqlAddPattern, dbFailOnError is
> > highlighted
> >
> > How can I modify the code so the manufacturer value i selected is also added
> > by the code?
> >
> > Thanks so much
> >
> > --
> > Lele

>

 
Reply With Quote
 
=?Utf-8?B?S2VuIFNoZXJpZGFu?=
Guest
Posts: n/a
 
      10th Sep 2006
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
>
>


 
Reply With Quote
 
=?Utf-8?B?TGVsZQ==?=
Guest
Posts: n/a
 
      13th Sep 2006
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
> >
> >

>

 
Reply With Quote
 
Terry Kreft
Guest
Posts: n/a
 
      13th Sep 2006
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
> > >
> > >

> >



 
Reply With Quote
 
=?Utf-8?B?S2VuIFNoZXJpZGFu?=
Guest
Posts: n/a
 
      13th Sep 2006


"Lele" wrote:

> 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
> > >
> > >

> >

 
Reply With Quote
 
=?Utf-8?B?TGVsZQ==?=
Guest
Posts: n/a
 
      14th Sep 2006
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
> > > >
> > > >
> > >

>
>
>

 
Reply With Quote
 
=?Utf-8?B?TGVsZQ==?=
Guest
Posts: n/a
 
      14th Sep 2006
Thanks for your help on this. I have been using the code you suggested, and
am making progress, but I now have a new 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.

Thanks so much.


Lele
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding values to a combo box jbear@wilmingtontrust.com Microsoft Excel Programming 2 1st Dec 2006 04:12 PM
Adding values in combo box on form =?Utf-8?B?RGVubmlzIF9N?= Microsoft Access Forms 5 6th Mar 2006 03:41 PM
Adding values in a combo box when value entered is not the key value =?Utf-8?B?V2VuZHk=?= Microsoft Access Forms 2 26th Oct 2003 10:58 PM
Adding values to Combo box values Mercy Microsoft Access Forms 4 18th Sep 2003 04:50 AM
adding values to combo box mark Microsoft Outlook Form Programming 2 22nd Jul 2003 04:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:06 AM.