Inserting a function within a sub in VBA

mercredi 25 février 2015

I need help fixing this code. I am new at VBA in access and I am working on an application I didn't develop but I am maintaining.




Code:



Private Sub Command122_Click()

Dim formName As String



formName = getFormName(tblName)



DoCmd.OpenForm (formName)

DoEvents

Forms(formName).FilterOn = False

Forms(formName).Combo94.Value = (myreference)

Forms(formName).Filter = "DeptID = '" & Forms(formName).Combo94.Value & "'"

Forms(formName).FilterOn = True

Forms(formName).Controls(fieldName).SetFocus

DoCmd.Close acForm, Me.Name

End Sub







Public Function myreference() As String



SELECT ID FROM tblSiteInfo WHERE ( DeptID = " & DeptID & " )

End Function



I am trying to to write afunction that translates the deptid into a table 'id (myreference)



Thanks in advance

Inserting a function within a sub in VBA

0 commentaires:

Enregistrer un commentaire

Labels