Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2003
    Location
    Canada
    Posts
    65

    Unanswered: Passing values between forms

    Hi!

    I currently set up 2 forms representing 2 different sections of a database. The main form prompt the user to enter an ID which the form uses to display the fields of that specific record. Now, how can I pass that ID to the next form?

    Once control is passed on to the second form, I want to close the main form also.

    There are 6 more forms that I will have to create but I need to resolve this problem before I start creating them.

    Please help.

  2. #2
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    You could pass it in as an OpenArgs, or pull it from the form after th e 2nd is open, or have a global variable to pull it from. Take your pick.

  3. #3
    Join Date
    Oct 2003
    Location
    Canada
    Posts
    65
    How do you declare a global variable? Do you declare it as public var and then insert the code as a different module?

  4. #4
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    You have to create a module and define it there ... Ex:

    Public MyVariableName As VariableType

  5. #5
    Join Date
    Aug 2003
    Location
    Argentina
    Posts
    465
    This code in the main form declare the public variable
    __________________________________________________ ___
    Option Compare Database
    Option Explicit
    Public PathBaseDatos As String

    Function CargarPath()
    Dim varX As Variant
    varX = DLookup("[txtLDBFilePath]", "Tbl Nros Comprobantes", "[CODCOM] = 1")
    PathBaseDatos = varX
    End Function
    __________________________________________________ __

    This code in other form use the public variable

    Private Sub Form_Open(Cancel As Integer)
    Dim dbs As Database, dbs1 As Database
    Dim rst As Recordset
    Dim stDocName As String

    stDocName = "Consulta CD Movimientos Masivos Eliminacion"
    DoCmd.OpenQuery stDocName, acNormal, acEdit

    Set dbs = OpenDatabase(PathBaseDatos) '<--------------- public variable
    Set dbs1 = CurrentDb

    Set rst = dbs1.OpenRecordset("Tbl CD Movimientos Masivos")

    If rst.BOF And rst.eof Then
    Forms![AltasCD Masivos].Section(0).Visible = False
    rst.Close
    Set dbs = Nothing
    GoTo Fin
    Else
    Forms![AltasCD Masivos].RecordSource = "Tbl CD Movimientos Masivos"
    rst.Close
    Set dbs = Nothing
    End If
    Fin:

    Me!RecDesde.SetFocus
    __________________________________________________ __


    Ok....
    Saludos
    Norberto

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •