1. Here is the Code exactly as it is in the Form for the event. I followed your template best I could. I colored the Debug error in red and the popup problem in green. reminder about the popup problem: The msgBox popsup even though the PKSalesID is chosen. You told me to place the Code:
Datecreated = Date()
I have a Date field that is the Date created but the default value is already Date(). Do I still need to place your code in there?
Private Sub cmdCreateQuote_Click()
If IsNull(Me.QuoteNumber) Or Me.QuoteNumber = "" Then
Dim sString, sSql As String
Dim rs As ADODB.Recordset
Dim ipkSalesID, i As Integer
Dim dtDate As Date
dtDate = Date
If IsNull(QuoteNumber) Or Me.QuoteNumber = "" Then
MsgBox "Please select your SalesID", vbCritical Exit Sub
Else
ipkSalesID = Me.PKSalesID
End If
sSql = "Select * From Quote Where [PKSalesID] = " & ipkSalesID & _
" AND [Date] = #" & dtDate & "#"
Set rs = New ADODB.Recordset
rs.Open sSql, CurrentProject.Connection, adOpenDynamic, adLockOptimistic
i = 1
Do Until rs.EOF
i = i + 1
rs.MoveNext
Loop
End If
rs.Close
sString = "Q-" & Me.PKSalesID & "-" & CStr(dtDate) & " (" & i & ")"
Me.QuoteNumber = sString
Else
MsgBox "There is already a Quote Number.", vbCritical
End If
End Sub
|