ross_petersen
New member
- Local time
- Today, 11:04
- Joined
- Oct 7, 2024
- Messages
- 2
Hi everyone
I have four tables as follows:
When I go to the Del Details, I am aiming to insert a new record based upon the data in the Resource Order and Resource Order Details.
Here is the code:
The problem is that up to (and including the following line) everything is fine:
However, somewhere in the following four(4) lines, something goes wrong
I am expecting to see when I look at the combo box, it should show a particular value being chosen.
If I look at the immediate window, Me.cboProductQtyType.Value does have the value I am expecting. Instead all it shows when I look at the combo box once the procedure has completed is an empty box.
I am puzzled.
Can anybody throw some light on this please?
TIA
Ross
I have four tables as follows:
- tblResourceOrders
- tblResourceOrderDetails
- tblResourceOrderDelivery
- tblResourceOrderDelDetails
When I go to the Del Details, I am aiming to insert a new record based upon the data in the Resource Order and Resource Order Details.
Here is the code:
Code:
Private Sub Form_BeforeInsert(Cancel As Integer)
' pick up data from frmResourceOrders (details) and insert them into the appropriate controls
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strSQL As String
Dim sql As String
Dim lngResOrderDetID As Long
Dim lngProdQtyType As Long
Dim intQty As Integer
Dim intI As Integer
intI = 0
Set cnn = New ADODB.Connection
Set cnn = CurrentProject.Connection
Set rs = New ADODB.Recordset
strSQL = "SELECT * FROM qryResOrderDelDet_Insert_Details " _
& "WHERE ResourceOrderID = " & Me.Parent.Parent.txtResourceOrderID
With rs
.ActiveConnection = cnn
.CursorLocation = adUseServer
.CursorType = adOpenKeyset
.LockType = adLockReadOnly
.Open strSQL, , , , adCmdText
If .RecordCount > 0 Then
' move to the first record returned and assign
.MoveFirst
lngResOrderDetID = ![ResourceOrderdetailID]
lngProdQtyType = ![ProductQtyType]
intQty = ![Qty]
Me.txtResOrderDetailID = lngResOrderDetID
For intI = 0 To Me.cboProductQtyType.ListCount - 1
If Me.cboProductQtyType.Column(0, intI) = lngProdQtyType Then
Me.cboProductQtyType.SetFocus
Me.cboProductQtyType.Dropdown
Me.cboProductQtyType.Selected(intI) = True
Me.cboProductQtyType.Value = lngProdQtyType
Exit For
End If
Next intI
Me.txtQty = intQty
End If
End With
rs.Close
cnn.Close
Set rs = Nothing
Set cnn = Nothing
End Sub
The problem is that up to (and including the following line) everything is fine:
Code:
If Me.cboProductQtyType.Column(0, intI) = lngProdQtyType Then
However, somewhere in the following four(4) lines, something goes wrong
Code:
Me.cboProductQtyType.SetFocus
Me.cboProductQtyType.Dropdown
Me.cboProductQtyType.Selected(intI) = True
Me.cboProductQtyType.Value = lngProdQtyType
I am expecting to see when I look at the combo box, it should show a particular value being chosen.
If I look at the immediate window, Me.cboProductQtyType.Value does have the value I am expecting. Instead all it shows when I look at the combo box once the procedure has completed is an empty box.
I am puzzled.
Can anybody throw some light on this please?
TIA
Ross
Last edited: