Hey guys, need your kind help on this one please. I saw similar threads in the forum which did not solve my problem.
My form FrmAtzPDC has a list named LstPDC.
I want to click in the list and populate frm fields in order to be able to Change, Delete, etc.
I have declared “Option Explicit” on the top of the code. I set LstPDC propertie for new entries as No.
The list source query includes every single field from the Table updated by FrmAtzPDC however when I built LstPDC I hided some fields that are irrelevant to show in FrmAtzPDC.
This is the code I am using with no success:
What am I missing?Code:Private Sub Form_Load() Me.Caption = "Atualização do Plano de Contas" ‘ Enabling buttons Me.bt_novo.Enabled = True Me.bt_alterar.Enabled = False Me.Bt_salvar.Enabled = False Me.bt_excluir.Enabled = False End Sub Private Sub Form_Open(Cancel As Integer) ‘ cleaning up eventual bad record Dim SQL As String DoCmd.SetWarnings False SQL = "DELETE * FROM TblPlanoDeContas WHERE CTACLASSE is null" SQL = "DELETE * FROM TblPlanoDeContas WHERE CTANUM is null" SQL = "DELETE * FROM TblPlanoDeContas WHERE CTATIPOFV is null" SQL = "DELETE * FROM TblPlanoDeContas WHERE CTATIPOCE is null" SQL = "DELETE * FROM TblPlanoDeContas WHERE CTAGRUPO is null" SQL = "DELETE * FROM TblPlanoDeContas WHERE CTANOME is null" SQL = "DELETE * FROM TblPlanoDeContas WHERE CTADESCR is null" DoCmd.RunSQL SQL DoCmd.SetWarnings = True Me.Requery Me.LstPDC.Requery End Sub Private Sub LstPDC_Click() ‘ Trying to load form fields based on the list Me.Caption = "Atualização do Plano de Contas" On Error Resume Next Dim intrec As Integer intrec = Me!LstPDC.Column(0) ‘variable is the list primary key Forms![FrmAtzPDC].SetFocus ‘to set focus on the form I am already in Forms![FrmAtzPDC].[CTAID].Enabled = True ‘to ensure form primary key is enabled DoCmd.GoToControl "CTAID" 'to set focus on form primary key DoCmd.FindRecord intrec 'to find the desired record according to the variable value End Sub