Results 1 to 5 of 5

Thread: Importing Access forms into VB

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    Brossard, Québec, Canada
    Posts
    241

    Post

    Is there a way (utility or something) to import my Ms-Access forms into VB even if I don't have the code... I would like to be able to do this

  2. #2
    Lively Member
    Join Date
    Aug 1999
    Location
    Blackpool, England
    Posts
    87

    Post

    try this http://www.devx.com/free/products/pg...ontent_id=3702
    It is costly $349 but it is the only way I have found

  3. #3
    Addicted Member
    Join Date
    Oct 1999
    Location
    Oporto, Portugal
    Posts
    134

    Post

    This "litle" code will help you (I think). It allows you to Print a Report and open a Form contained in an Access Database.


    Option Explicit

    'API Declarations
    Private Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

    'API Message Constants
    Private Const SW_MAXIMIZE = 3
    Private Const SW_NORMAL = 1

    '------ >Module

    Private Function PtrToString(lpwString As Long) As String
    'Convert a LPWSTR pointer to a VB string
    Dim Buffer() As Byte
    Dim nLen As Long

    If lpwString Then
    nLen = lstrlenW(lpwString) * 2
    If nLen Then
    ReDim Buffer(0 To (nLen - 1)) As Byte
    CopyMem Buffer(0), ByVal lpwString, nLen
    PtrToString = Buffer
    End If
    End If
    End Function

    Public Function GetUsers(ServerName As String) As Long
    Dim lpBuffer As Long
    Dim nRet As Long
    Dim EntriesRead As Long
    Dim TotalEntries As Long
    Dim ResumeHandle As Long
    Dim uUser As USER_INFO_API
    Dim bServer() As Byte
    Dim i As Integer

    If Trim(ServerName) = "" Then
    'Local users
    bServer = vbNullString
    Else
    'Check the syntax of the ServerName string
    If InStr(ServerName, "\\") = 1 Then
    bServer = ServerName & vbNullChar
    Else
    bServer = "\\" & ServerName & vbNullChar
    End If
    End If
    i = 0
    ResumeHandle = 0
    Do
    'Start to enumerate the Users
    If Trim(ServerName) = "" Then
    nRet = NetUserEnum(vbNullString, 10, FILTER_NORMAL_ACCOUNT, lpBuffer, 1, EntriesRead, TotalEntries, ResumeHandle)
    Else
    nRet = NetUserEnum(bServer(0), 10, FILTER_NORMAL_ACCOUNT, lpBuffer, 1, EntriesRead, TotalEntries, ResumeHandle)
    End If
    'Fill the data structure for the User
    If nRet = ERROR_MORE_DATA Then
    CopyMem uUser, ByVal lpBuffer, Len(uUser)
    UserInfo(i).Name = PtrToString(uUser.Name)
    UserInfo(i).Comment = PtrToString(uUser.Comment)
    UserInfo(i).UserComment = PtrToString(uUser.UserComment)
    UserInfo(i).FullName = PtrToString(uUser.FullName)
    i = i + 1
    End If
    If lpBuffer Then
    Call NetApiBufferFree(lpBuffer)
    End If
    Loop While nRet = ERROR_MORE_DATA
    'Return the number of Users
    GetUsers = i
    End Function

    '------> Usage

    'add the Microsoft Access 8.0 Object Library to the project references...Create a Form with three Command Buttons and enjoy with this code
    'Create a new Access Instance
    Dim appAccess As New Access.Application

    Public Sub MaximizeAccess()
    'Maximize Access Application
    Dim hWnd As Long

    hWnd = FindWindow("OMain", "Microsoft Access")
    If hWnd <> 0 Then
    ShowWindow hWnd, SW_NORMAL
    ShowWindow hWnd, SW_MAXIMIZE
    End If
    End Sub

    'Open an Access Form
    Private Sub Command1_Click()
    appAccess.DoCmd.OpenForm "Categories", acNormal, , , , acDialog
    End Sub

    'Print an Access Report
    Private Sub Command2_Click()
    appAccess.DoCmd.OpenReport "Catalog", acViewNormal
    End Sub

    Private Sub Command3_Click()
    MaximizeAccess
    End Sub

    'Open a Database
    Private Sub Form_Load()
    appAccess.OpenCurrentDatabase "C:\programmi\Microsoft Visual Studio\VB98\nwind.mdb", True
    End Sub

    'Close the database and the Access Instance
    Private Sub Form_Unload(Cancel As Integer)
    On Error Resume Next
    appAccess.CloseCurrentDatabase
    appAccess.DoCmd.Quit acQuitSaveNone
    End Sub


    ------------------
    Jorge Ledo
    j_ledo@hotmail.com
    Portugal

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    Brossard, Québec, Canada
    Posts
    241

    Post

    Thanks Steve... I'm still trying to figure out the login thing. they ask for a password (?!?!?)

    Jorge... with that code... do you need the access run time to open the form??

  5. #5
    Addicted Member
    Join Date
    Oct 1999
    Location
    Oporto, Portugal
    Posts
    134

    Post

    Yeah U need access installed on the machine.

    ------------------
    Jorge Ledo
    j_ledo@hotmail.com
    Portugal

Posting Permissions

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



Click Here to Expand Forum to Full Width