Q
quixote
I asked this yesterday but didn't really understand the
answers. I have the following abbreviated function
created. I need the input values to be values from another
table, but I'm not sure how to do this. I would like to
automate the task via macro or whatever. The function
populates a table. I know what I want to do but am not
sure of how.
Logic I want to do:
Go through each record in myTable and insert
myTable.Field1, myTable.Field2, myTable.Field3, etc into
the following Function:
Public Function GetLetter(Com, Model, LineItem, PO, Qty)
Dim db As DAO.Database
Dim strSQLA As String
Dim strSQLB As String
Set db = CurrentDb
If LineItem < 10 Then
Select Case Qty
Case 1
strSQLA = "INSERT INTO tblTraveller (COM, Model,
Traveller)" _
& "VALUES('" & Com & "', '" & Model & "', ' " & PO & "0" &
LineItem & "A" & "')"
db.Execute strSQLA
Case 2
strSQLA = "INSERT INTO tblTraveller (COM, Model,
Traveller)" _
& "VALUES('" & Com & "', '" & Model & "', ' " & PO & "0" &
LineItem & "A" & "')"
strSQLB = "INSERT INTO tblTraveller (COM, Model,
Traveller)" _
& "VALUES('" & Com & "', '" & Model & "', ' " & PO & "0" &
LineItem & "B" & "')"
db.Execute strSQLA
db.Execute strSQLB
End Select
End If
If LineItem > 9 Then
Select Case Qty
Case 1
strSQLA = "INSERT INTO tblTraveller (COM, Model,
Traveller)" _
& "VALUES('" & Com & "', '" & Model & "', ' " & PO &
LineItem & "A" & "')"
db.Execute strSQLA
Case 2
strSQLA = "INSERT INTO tblTraveller (COM, Model,
Traveller)" _
& "VALUES('" & Com & "', '" & Model & "', ' " & PO &
LineItem & "A" & "')"
strSQLB = "INSERT INTO tblTraveller (COM, Model,
Traveller)" _
& "VALUES('" & Com & "', '" & Model & "', ' " & PO &
LineItem & "B" & "')"
db.Execute strSQLA
db.Execute strSQLB
End Select
End If
End Function
answers. I have the following abbreviated function
created. I need the input values to be values from another
table, but I'm not sure how to do this. I would like to
automate the task via macro or whatever. The function
populates a table. I know what I want to do but am not
sure of how.
Logic I want to do:
Go through each record in myTable and insert
myTable.Field1, myTable.Field2, myTable.Field3, etc into
the following Function:
Public Function GetLetter(Com, Model, LineItem, PO, Qty)
Dim db As DAO.Database
Dim strSQLA As String
Dim strSQLB As String
Set db = CurrentDb
If LineItem < 10 Then
Select Case Qty
Case 1
strSQLA = "INSERT INTO tblTraveller (COM, Model,
Traveller)" _
& "VALUES('" & Com & "', '" & Model & "', ' " & PO & "0" &
LineItem & "A" & "')"
db.Execute strSQLA
Case 2
strSQLA = "INSERT INTO tblTraveller (COM, Model,
Traveller)" _
& "VALUES('" & Com & "', '" & Model & "', ' " & PO & "0" &
LineItem & "A" & "')"
strSQLB = "INSERT INTO tblTraveller (COM, Model,
Traveller)" _
& "VALUES('" & Com & "', '" & Model & "', ' " & PO & "0" &
LineItem & "B" & "')"
db.Execute strSQLA
db.Execute strSQLB
End Select
End If
If LineItem > 9 Then
Select Case Qty
Case 1
strSQLA = "INSERT INTO tblTraveller (COM, Model,
Traveller)" _
& "VALUES('" & Com & "', '" & Model & "', ' " & PO &
LineItem & "A" & "')"
db.Execute strSQLA
Case 2
strSQLA = "INSERT INTO tblTraveller (COM, Model,
Traveller)" _
& "VALUES('" & Com & "', '" & Model & "', ' " & PO &
LineItem & "A" & "')"
strSQLB = "INSERT INTO tblTraveller (COM, Model,
Traveller)" _
& "VALUES('" & Com & "', '" & Model & "', ' " & PO &
LineItem & "B" & "')"
db.Execute strSQLA
db.Execute strSQLB
End Select
End If
End Function