calling is not working

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • khokhart
    New Member
    • Nov 2008
    • 1

    calling is not working

    Hello I am not an experienced programmer.
    I need to call a sub from module 1 to module 2
    I am using bellow mentioned code to do so but its not working please help me to get this thing solved.

    Sub testhide()
    Call Module1.AdminHi de
    End Sub
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    I'll add a bit also for you, see if you can salvage for parts...

    Module code:

    [CODE=VB]

    Public form2 As String

    Public Sub frame()

    'you need two options buttons a frame
    If Option1 Is Selected Then
    form2.Frame2 = small

    ElseIf Option2 Is Selected Then
    form2.Frame3 = medium
    Else
    MsgBox ("what happened?")
    End If

    End Sub
    [/CODE]

    Form 1 code:

    [CODE=VB]

    'this is used as a splash screen
    please ignore this form, you can just use form 2 code
    Private Sub Continue_button _Click()
    Form1.Visible = False
    form2.Visible = True

    End Sub
    [/CODE]

    Form 2 code:

    [CODE=VB]

    Private Sub Command1_Click( )

    'we are assigning media a number to be used later
    If Option1 = True Then
    media = 1
    ElseIf Option2 = True Then
    media = 2
    End If

    'if media equals 1 a certain frame pops up with additional field data..
    'frames are layered depending on which option is pressed
    If media = 1 Then
    Frame2.Visible = True
    Frame3.Visible = False
    'media 2 can represent, in my case video frame
    'media 1 can represent DVD frame, data on frame
    ElseIf media = 2 Then
    Frame2.Visible = False
    Frame3.Visible = True
    End If

    End Sub
    [/CODE]

    I am sure there's more work to be done wth it, but see if you can gather anything, let us know.

    Good luck with the project!

    Dököll

    Comment

    • Dököll
      Recognized Expert Top Contributor
      • Nov 2006
      • 2379

      #3
      Let's try this one instead, I'll modify the other one momentarily, the message box is not firig, but here's on the fires an SQL command...

      [CODE=VB]

      Form code:

      'Exit database button closes the form completely
      Private Sub ExitDataBase_Cl ick()
      On Error GoTo Err_ExitDataBas e_Click
      'On Load of your form to check all incomplete items
      Call RunMultiSQL

      Dim intStore As Integer
      'Count of incomplete items that are past the Expected Completion Date
      intStore = DCount("[qryOverDueJobs. ID]", "[qryOverDueJobs]", "[qryOverDueJobs. Incomplete] =0")
      'If count of incomplete items is zero display a certain form
      [/CODE]

      In this case, I was setting a checkbox to checked if system info met certain criteria, but the idea is you are runningthe module code from here using Call RunMultiSQL

      This should work in VB o VBA, I believe...

      [CODE=VB]

      Module code:

      Option Compare Database

      Sub RunMultiSQL()

      DoCmd.SetWarnin gs False
      DoCmd.RunSQL ("UPDATE DETData SET Incomplete = True WHERE Emailed = True")
      DoCmd.SetWarnin gs False

      End Sub

      [/CODE]

      Comment

      • rpicilli
        New Member
        • Aug 2008
        • 77

        #4
        Hi There.


        The sub that you're calling on module2 from module1 should be public. To do that in the declaration of your sub add the word public instead private.

        Code:
        Public mySub 
        ...
        ...
        End mySub
        Hope this help you

        Rpicilli

        Comment

        Working...