change that procedure for him to be faster

  • Thread starter Thread starter Frank Dulk
  • Start date Start date
F

Frank Dulk

How to do to change that procedure for him to be faster.

Dim ContSelos As Integer
ContSelos = DCount("*", "QryContSelosInsp", "")

If ContSelos < 1 Then
MsgBox " That stamp doesn't belong to that inspector ", vbCritical
Me.Undo
End If

End Sub
 
Your code only needs to know if there is at least one, so a DLookup()
returning something woud be faster than a DCount() which has to locate the
full number.

DLookup() is also slow if you are performing it inside a loop. You can get a
faster result by opening a recordset. Concatenating the values from the form
into the string may also be better than a saved query that refers to the
form, e.g.:

Dim strSQL as String
Dim rs As DAO.Recordset
strSQL = "SELECT TOP 1 FROM MyTable WHERE (StampID = " & Me.StampID & ")
(AND InspectorID = " & Me.InspectorID & ");"
Set rs = dbEngine(0)(0).OpenRecordset(strSQL)
If rs.RecordCount = 0 Then
MsgBox ...
End If
rs.Close
Set rs = Nothing
 
really got better plenty and that as he/she would do to be faster use A2K.

Private Sub Medidor_AfterUpdate()
'On Error Resume Next
Me.Cod_Instalação = Forms!frmEscolhaBaixa!Instalação
Me.Marca = Forms!frmEscolhaBaixa!Marca
Me.Modelo = Forms!frmEscolhaBaixa!Modelo
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70


Dim ContModelo As Integer
Dim QtModeloTable As Integer

ContModelo = Forms!frmEscolhaBaixa!Modelo.Column(2)
QtModeloTable = DLookup("qtModelo", "QryContModelo", "")


If QtModeloTable > ContModelo Then
MsgBox (" You cannot lower more stamps for that model, choose
another model "), vbCritical
Me.Marca = Null
Me.Medidor = Null
Me.Cod_Instalação = Null
Me.Selo = Null
Me.Modelo = Null
Me.Tampa = Null

Exit Sub
End If
 
Back
Top