Hello there, I used to have this code for generate fields from Data1 to Data2, like A001 to A005, it would generate A001, A002, A003, A004, A005.
So it works with this code.
---- Now what I wanted to do is add error messages when the final user didnt digit a form like ALPHA,NUMERIC,NUMERIC,NUMERIC.
---- If the Alpha variable not in MAYUS.. then display mayus error.
---- And when the user put on the field data1 A005 and on field data2 A004 that it showed it cant generate lower data.
So far I got this.
Could anyone help with this?
So it works with this code.
Code:
Set db = CurrentDb
Set rs = db.OpenRecordset("Almacenes")
For x = Val(Right(Me!Data1, 3)) To Val(Right(Me!Data2, 3))
rs.AddNew
rs!Almacen = Left(Me!Data1, 1) & String(3 - Len(x), "0") & x
rs.Update
Me.Refresh
Next
---- Now what I wanted to do is add error messages when the final user didnt digit a form like ALPHA,NUMERIC,NUMERIC,NUMERIC.
---- If the Alpha variable not in MAYUS.. then display mayus error.
---- And when the user put on the field data1 A005 and on field data2 A004 that it showed it cant generate lower data.
So far I got this.
Code:
Private Sub Command5_Click()
Dim fAlpha As Integer: Asc (Left(Me!Data1, 1))
Dim fNumeric As Boolean: IsNumeric (Right(Me!Data1, 3))
Dim sAlpha As Integer: Asc (Left(Me!Data2, 1))
Dim sNumeric As Boolean: IsNumeric (Right(Me!Data2, 3))
If (fAlpha < 65) Or (fAlpha > 90) Or _
(sAlpha < 65) Or (sAlpha > 90) Or _
(Not fNumeric) Or (Not sNumeric) Then
MsgBox "Theres been an error, try digit something like.. A001 - A005..", , "buhoruS says:"
Exit Sub
End If
Set db = CurrentDb
Set rs = db.OpenRecordset("Almacenes")
For x = Val(Right(Me!Data1, 3)) To Val(Right(Me!Data2, 3))
rs.AddNew
rs!Almacen = Left(Me!Data1, 1) & String(3 - Len(x), "0") & x
rs.Update
Me.Refresh
Next
End Sub
Could anyone help with this?