> OK, I see the problem. You cannot set the SoftwareID variable to a SQL
> statement string when the SoftwareID variable is Dim'd as an Integer.
>
> I assume that you want to read the value of the SoftwareID field from the
> Software table and use that value as the value of the SoftwareID variable;
> is that correct? If yes, replace this line of code
>
> SoftwareID = "SELECT Software.[ID] FROM Software where Software.[Name] = '"
> + cmbSoftware.Value + " AND ServerID = '" + ServerID = "';"
>
>
> with these lines of code:
>
> SoftwareID = DLookup("ID", "Software", "[Name] = '" & _
> cmbSoftware.Value & "' AND [ServerID] = '" & _
> ServerID & "'")
>
> --
>
> Ken Snell
> <MS ACCESS MVP>
>
http://www.accessmvp.com/KDSnell/>
>
> "short" <short[ at ]discussions.microsoft.com> wrote in message
> news:67EB4A83-A17B-4A4D-9D27-D394330AFEF5[ at ]microsoft.com...
> > Both fields in the Node_software table are number fields. When I run the
> > query and look in the Node_software table, I get the nodeId number but no
> > softwareID
> >
> > "Ken Snell (MVP)" wrote:
> >
> >> A text field is one where the Data Type property of the field in the
> >> table
> >> is Text or Memo. A Text field can contain numeric values, but they are
> >> not
> >> numbers, they are characters that look like numbers.
> >>
> >> I see that I misread your original post. SoftwareID is dim'd as an
> >> Integer,
> >> not a Text -- my mistake.
> >>
> >> Are you sure that ID field is not NULL when your code runs?
> >>
> >> What are the Data Type properties of the two fields in the Node_Software
> >> table?
> >>
> >> Also, the error message suggests that it did add the new record, but that
> >> one field was given a NULL value. Which field is being assigned NULL by
> >> the
> >> query when it runs and gives you the error? Look at the table after you
> >> run
> >> the query and see.
> >>
> >> --
> >>
> >> Ken Snell
> >> <MS ACCESS MVP>
> >>
http://www.accessmvp.com/KDSnell/> >>
> >>
> >> "short" <short[ at ]discussions.microsoft.com> wrote in message
> >> news:1BD37B2B-55AB-478E-830F-1F2B94C330A4[ at ]microsoft.com...
> >> > by text field does that include numbers?
> >> >
> >> > "Ken Snell (MVP)" wrote:
> >> >
> >> >> SoftwareID is a string variable, which is being put into the
> >> >> SoftwareID
> >> >> field, so I assume that the SoftwareID field is a text field.
> >> >> Therefore,
> >> >> you
> >> >> must delimit the string text with " characters so that the insert
> >> >> query
> >> >> will
> >> >> recognize the data as text:
> >> >>
> >> >> sql = "INSERT INTO Node_Software([NodeID], [SoftwareID]) VALUES ("" &
> >> >> NodeID & "", """" & SoftwareID & """")"
> >> >>
> >> >> --
> >> >>
> >> >> Ken Snell
> >> >> <MS ACCESS MVP>
> >> >>
http://www.accessmvp.com/KDSnell/> >> >>
> >> >>
> >> >>
> >> >> "short" <short[ at ]discussions.microsoft.com> wrote in message
> >> >> news:010662AD-37A3-4914-AA0D-684EE1DC6BDA[ at ]microsoft.com...
> >> >> >I have a database that the users want to have a seperate table that
> >> >> >holds
> >> >> >the
> >> >> > primary keys of two other tables. So I create a table with both
> >> >> > tables
> >> >> > primary keys in it:
> >> >> > Software_Node
> >> >> > NodeID
> >> >> > SoftwareID
> >> >> > (made both pk both numbers)
> >> >> > which is connected to the Software and Node tables by their pk's.
> >> >> >
> >> >> > Now on the node form I have it where the user selects the software,
> >> >> > and
> >> >> > then
> >> >> > enters the node and then pressed a button to add the node which is
> >> >> > supposed
> >> >> > to put in the PK's of the tables. So this is my code: (I posted this
> >> >> > a
> >> >> > few
> >> >> > days ago, but am now getting an error)
> >> >> >
> >> >> > Private Sub cmdNode_Click()
> >> >> > Dim NodeID As Integer
> >> >> > Dim SoftwareID As Integer
> >> >> > NodeID = ID
> >> >> > SoftwareID = "SELECT Software.[ID] FROM Software where
> >> >> > Software.[Name]
> >> >> > =
> >> >> > '"
> >> >> > + cmbSoftware.Value + " AND ServerID = '" + ServerID = "';"
> >> >> >
> >> >> > Dim sql As String
> >> >> >
> >> >> > sql = "INSERT INTO Node_Software([NodeID], [SoftwareID]) VALUES (""
> >> >> > &
> >> >> > NodeID & "", "" & SoftwareID & "")"
> >> >> >
> >> >> > MsgBox ("You have added a node")
> >> >> > DoCmd.RunSQL sql
> >> >> >
> >> >> > End Sub
> >> >> >
> >> >> > I keep getting an error message that MS Access can't append all the
> >> >> > records
> >> >> > in the appened query.. set 1 field(s) to Null due to conversion
> >> >> > failure
> >> >> >
> >> >> > anyone have any idea what I did wrong?
> >> >> >
> >> >> >
> >> >> >
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>
>
>
>