Hi folk, How are you All? I have below code it's work just fine by entered 100 record for each block and it's work fine but if i entered less than 100 record and close form and re-open it it's record new block even the previous block not completed entered. I'm looking forward for your help to prevent record new block number in case not completed the 100 record? and i try code in red but unfortunately it's not working. Thank you All.
Code:Const BlockSize = 100 Dim rsReceived As ADODB.Recordset Dim cn As Long, Tn As Long, Bn As Long, Bk As Long ---------------------------------------------------------------------- Private Sub txtICCID_KeyPress(KeyAscii As Integer) 'This check that all information has been entered and the saves the record Dim Nm As Double If KeyAscii = 13 And Not txtICCID.Locked Then If Len(txtICCID.Text) = 11 Or Len(txtICCID.Text) = 12 Then Nm = txtICCID.Text txtICCID.Text = Nm If Bk = 0 Then Bk = 1 TxBlock.Text = Format(Bk, "#,##") rsReceived.Find "number = '" & txtICCID.Text & "'" If rsReceived.EOF Then rsReceived.AddNew rsReceived.Fields(0) = txtICCID.Text rsReceived.Fields(1) = TxBlock.Text rsReceived.Fields(3) = dtpReceived.Value rsReceived.Fields(2) = 0 rsReceived.Fields(4) = 0 rsReceived.Fields(5) = 0 rsReceived.Update cn = cn + 1 TxCount.Text = cn txtICCID.Text = "" txtICCID.SetFocus If cn = BlockSize Then Bk = Bk + 1 MsgBox "Block Done" txtICCID.Locked = True txtICCID.SetFocus Else Bk = Bk End If Else MsgBox "Repeated" txtICCID.Text = "" End If Else txtICCID.Text = "" MessageBoxH Me.hwnd MsgBox "please enter 11 or 12 number!", vbCritical + vbMsgBoxRtlReading + vbMsgBoxRight, "Warning" Call OffMsg End If End If Exit Sub End Sub




Reply With Quote