I can't get one of my form to open with a specific value in one of its combo box. i tried to set the default value but nothing works
this is the code of the button that opens the form. it is set to return a set of services in the form's subform
the combo box is called: cboRefTypeSales and the control source is RefTypeSales
i'm trying to return the value: "Export" which is in tblTypesSales: TypesalesID = 31; TypesSales= Export
Private Sub cmdaddquote_Click()
Dim rst As New ADODB.Recordset
Dim lngQuoteID As Long
Const cFrmNa = "frmQuotation"
If MsgBox("Are you sure you want to add a new quotation?", vbQuestion + vbYesNo) = vbNo Then Exit Sub
With rst
.Open "SELECT * FROM tblQuotations WHERE 0", CurrentProject.Connection, adOpenStatic, adLockOptimistic
.AddNew
.Fields("QuoteDate") = Date
.Update
lngQuoteID = .Fields("QuotationID")
.Close
End With
CurrentProject.Connection.Execute "INSERT INTO tblServicesQuotation (RefQuotation, RefServices) " & _
" SELECT " & lngQuoteID & ", ServiceID FROM tblDefaultServices"
DoCmd.OpenForm cFrmNa
Forms(cFrmNa).Requery
Forms(cFrmNa).Recordset.FindFirst "QuotationID = " & lngQuoteID
End Sub
this is the code of the button that opens the form. it is set to return a set of services in the form's subform
the combo box is called: cboRefTypeSales and the control source is RefTypeSales
i'm trying to return the value: "Export" which is in tblTypesSales: TypesalesID = 31; TypesSales= Export
Private Sub cmdaddquote_Click()
Dim rst As New ADODB.Recordset
Dim lngQuoteID As Long
Const cFrmNa = "frmQuotation"
If MsgBox("Are you sure you want to add a new quotation?", vbQuestion + vbYesNo) = vbNo Then Exit Sub
With rst
.Open "SELECT * FROM tblQuotations WHERE 0", CurrentProject.Connection, adOpenStatic, adLockOptimistic
.AddNew
.Fields("QuoteDate") = Date
.Update
lngQuoteID = .Fields("QuotationID")
.Close
End With
CurrentProject.Connection.Execute "INSERT INTO tblServicesQuotation (RefQuotation, RefServices) " & _
" SELECT " & lngQuoteID & ", ServiceID FROM tblDefaultServices"
DoCmd.OpenForm cFrmNa
Forms(cFrmNa).Requery
Forms(cFrmNa).Recordset.FindFirst "QuotationID = " & lngQuoteID
End Sub