I fixed the MSCAL.OCX error - just had to unselect library reference. Now I get errors when forms try to load images I don't have. Commented out the lines. Closing forms wants to go back to login form which I never opened because of shift key bypass.
What should I use for a login? I tried admin/silvio00. Then I get an input popup for LOGIN!USER (why?) so I enter admin again. Menu Principal form opens. I select Nome Buscar and this looks like where need to be. Now the listbox has records. I click the first one and frmCadastro opens but Salvar Inclusio button is not available. How do I quit this form?
Now I click Adc Avaliado button to open frmCadastro and Salvar Inclusio button is available.
Why does frmCadastro have a RecordSource that is a query with an INNER JOIN? What is tblNumLdAFG for?
This is really involved. I found out this much. Code is setting value of QTEDIAS field when frmCadastro opens to new record. This initiates the record but even with this commented out and only user input to form, SendKeys is still not working. I confirmed that manually hitting ESC key does reverse the code setting of QTEDIAS and user input and record does not commit. I don't know why the SendKeys won't work. It always has for me. So back to looking at your original code.
Keep getting that annoying LOGIN!USER popup when close frmCadastro.
Think I forgot something in my code (which is moot since the SendKeys won't work):
Code:
If MsgBox("WARNING! One or more required fields (CPF, NAME, FIN, NAT, TIP, MOT, and INSTREQ) not entered." _
& "Incomplete record will not be saved. Do you want to complete?", vbYesNo, Me.Caption) = vbNo Then
booCancel = True
Else
Exit Sub
End If
This code works to not save new record if it is incomplete:
Code:
If Me.Dirty Then
If IsNull(CPF) Or IsNull(Name) Or IsNull(FIN) Or IsNull(NAT) Or IsNull(TIP) Or IsNull(MOT) Or IsNull(INSTREQ) Then
If MsgBox("WARNING! One or more required fields (CPF, NAME, FIN, NAT, TIP, MOT, and INSTREQ) not entered." _
& "Incomplete record will not be saved. Do you want to complete?", vbYesNo, Me.Caption) = vbNo Then
DoCmd.RunCommand acCmdSaveRecord
CurrentDb.Execute "DELETE FROM tblCadastro WHERE CADID=" & Me.CADID
Else
Exit Sub
End If
ElseIf MsgBox("The record was changed. Do you want to save it?", vbQuestion + vbYesNo, Me.Caption) = vbNo Then
'trying to undo edits to existing record but this button is not available for existing record so cannot test
SendKeys "{ESC}", True
SendKeys "{ESC}", True
End If
End If
DoCmd.Close
My next step would be to use BeforeUpdate event but you have custom function call in that event property. I would change the Function to a Sub (because it does not return a value to the calling procedure) and call the Sub in BeforeUpdate VBA event procedure. That way can have other code in the BeforeUpdate event as well.
Forms opened in popup or modal state really get in the way of debugging. I rarely use those and only after everything works properly. I prefer Overlapping Windows and never use Tabbed Documents.
I would not save SEXID for the gender - I would delete that field and just save M/F.