Please help me customize this code (1 Viewer)

Harley

Registered User.
Local time
Yesterday, 22:48
Joined
Dec 8, 2005
Messages
54
Below is the beginning of some code in a database that I need help with. I do not know Visual Basic. The form works great unless someone forgets to enter a lot number. If that happens an error is generated. I would like to put an IF statement in here (I have no idea how or where to put it) that would generate a message to the effect "Please enter a lot number" if they forget. Thanks in for your help. Below is the beginning of the code.

Private Sub Command71_Click()


Dim tempLotNumber1 As String
Dim tempLotNumber2 As String
Dim tempProdName As String
Dim tempAssay As Double
Dim MaxAssay As Double
Dim MinAssay As Double
Dim dbs As Database
Dim dbs1 As Database
Dim tmp As Recordset
Dim tmp1 As Recordset
Dim tmp2 As Recordset
Dim TempDate As Date
Dim tempcount As Integer
Dim varResult As String
Dim idx As Index
Dim fld1 As field, fld2 As field
Dim strCriteria As String
Dim tempCOAMinAssay As Double
Dim tempCOAMaxAssay As Double
Dim tempCustomer As String
Dim tempNewProductName As String
Dim tempProductID As String
Dim tempProdName1 As String
Dim tempCustomer2 As String





tempLotNumber2 = Forms![Hydro COA]![LotNumber]
strCriteria = "[Lot #] = '" & tempLotNumber2 & "'"

'tempCustomer2 = Forms![Customer]

Set dbs1 = OpenDatabase("S:\common\Database\FormatePlant.mdb")


Set tmp1 = dbs1.OpenRecordset("Control Room", dbOpenDynaset)
' Find first matching record.
tmp1.FindFirst strCriteria
' Check if record is found.

If tmp1.NoMatch Then
MsgBox "No record found."
GoTo ENDSUB
Else
MsgBox "Record Found."
tempProdName = tmp1!ProductID
TempDate = tmp1!Date
tempAssay = tmp1![Blend Assay]
Forms![Hydro COA]![ProdName] = tempProdName
Forms![Hydro COA]![Manufacture] = TempDate
Forms![Hydro COA]![BAssay] = tempAssay


End If
 

supercharge

Registered User.
Local time
Yesterday, 19:48
Joined
Jun 10, 2005
Messages
215
Add this after your last 'Dim' statement

If Forms![Hydro COA]![LotNumber] <> "" Then
......

Add this to the end

Else
Msgbox "Please enter a Lot Number!"
End If
 

Harley

Registered User.
Local time
Yesterday, 22:48
Joined
Dec 8, 2005
Messages
54
That is the ticket! Thanks much supercharge! :)
 

Users who are viewing this thread

Top Bottom