How to call or run a module

I have a module that someone wrote and I need to run it....I have a button to call it..but I am not sure that I am doing this
Jass SainiAsked:
Who is Participating?
Rey Obrero (Capricorn1)Commented:
<I have a button to call it>

post the codes in the click event of this button..

also, you don't call a module, the module is where the Functions or Sub procedure
you call the Sub or the Function
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
If you have a Function in the Module, you can Call (run) it directly from the Events tab for the Button

Run a Function
Jass SainiAuthor Commented:
here is the Module..

I tried both and either work
Private Sub Transposer()

Dim db As DAO.Database
Dim tdfNewDef As DAO.TableDef
Dim fldNewField As DAO.field
Dim rstSource As DAO.Recordset, rstTarget As DAO.Recordset
Dim i As Integer, j As Integer, k As Integer

Set db = CurrentDb()

db.Execute "delete from tblFinal_Transposed where Change <> 'Initial'"

For k = 11 To 38 Step 3
    Call AddRecord(k)
Next k

End Sub

Private Sub AddRecord(field As Integer)

Set db = CurrentDb()
Set rstSource = db.OpenRecordset("Final_Table")
Set rstTarget = db.OpenRecordset("tblFinal_Transposed")



For j = 0 To rstSource.RecordCount - 1
        If rstSource.Fields(field) <> 0 Then
            rstTarget.Fields(0) = rstSource.Fields(1)
            rstTarget.Fields(1) = rstSource.Fields(2)
            rstTarget.Fields(2) = rstSource.Fields(3)
            rstTarget.Fields(3) = rstSource.Fields(4)
            rstTarget.Fields(4) = rstSource.Fields(field).Name
            rstTarget.Fields(5) = rstSource.Fields(field + 1)
            rstTarget.Fields(6) = rstSource.Fields(field + 2)
                For i = 7 To rstTarget.Fields.Count - 1
                    If rstTarget.Fields(i).Name = rstSource.Fields(5) Then
                        rstTarget.Fields(i) = rstSource.Fields(field)
                    Else: rstTarget.Fields(i) = 0
                    End If
                Next i
        End If
Next j


Open in new window

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
For my method ... change

Private Sub Transposer()
Public Function Transposer()


End Sub
End Function

and then in the Click Event of the button put

Jass SainiAuthor Commented:
Never Mind I figured it out!
Jass SainiAuthor Commented:
Thank You
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
You are welcome.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.