Hi everyone,
I have another question for you all. I have a form A in which I enter a number # and this number is stored in a table 1. In this same form A, I want to add a button. When I click this button I want it to look in a table 2 to see if the number # I entered is already there. If it is not there, I want form B to open and have the number # already in the field associated to it so I only have to fill in the rest. However, if it is already in the table 2(so it is already in the form B), I want it to open the form B and show all the fields that were previously entered including the number #.
Does someone know what VBA code I would need to enter in the Private Sub Button_Click()?
This is what I have now, but it does not work :
I have another question for you all. I have a form A in which I enter a number # and this number is stored in a table 1. In this same form A, I want to add a button. When I click this button I want it to look in a table 2 to see if the number # I entered is already there. If it is not there, I want form B to open and have the number # already in the field associated to it so I only have to fill in the rest. However, if it is already in the table 2(so it is already in the form B), I want it to open the form B and show all the fields that were previously entered including the number #.
Does someone know what VBA code I would need to enter in the Private Sub Button_Click()?
This is what I have now, but it does not work :
Code:
Private Sub RP_Click() If DLookup("NoRecomPaiem", "TblRecomPaiement", "NoRecomPaiem='" & Me.NoRecom & "'") Is Null Then DoCmd.OpenForm "FrmRecomPaiement", , , , acFormAdd Forms!FrmRecomPaiement!NoRecomPaiem = Me!NoRecom Forms!FrmRecomPaiement!NoRecomPaiem = Me!NoRecom Forms!FrmRecomPaiement!DateRecom = Me!DateRecom Forms!FrmRecomPaiement!NoFacture = Me!NoFacture DoCmd.Close acForm, "FrmFacture" Else Dim db As DAO.Database Dim rst As DAO.Recordset On Error GoTo Err_RP_Click DoCmd.OpenForm "FrmRecomPaiement" Set rst = Forms!FrmRecomPaiement.Recordset.Clone rst.FindFirst "[NoRecomPaiem] = " & Me.NoRecom Forms!FrmRecomPaiement.Bookmark = rst.Bookmark Exit_RP_Click: Exit Sub Err_RP_Click: MsgBox Err.description Resume Exit_RP_Click End If End Sub
Comment