Results 1 to 3 of 3
  1. #1
    tracamonali is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    4

    open report from a vb form

    I wish to open an Access report which should read a value from the vb form. The access report should pick up the Hospital# from a textbox and only one record should be opened. Here is my code:

    Private Sub cmdCallLog_Click()
    Dim strWhere As String
    strWhere = "'" & txtHospID.Text & "'"


    Set mAcc = New Access.Application
    mAcc.OpenCurrentDatabase "............mdb"

    mAcc.DoCmd.OpenReport "CTX_HDCALLS_rpt", acViewPreview, , strWhere
    mAcc.Visible = True


    End Sub

    My problem is a popup window opens and request for Hospital# when I set up the criteria in the access report. ["Enter hospital Number"]. I do not wish this to happen. The report should be able to read Hospital# from the variable strwhere. Where am I going wrong? Any help appreciated.

  2. #2
    SoftwareMatters is offline Access VBA Developers
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2009
    Location
    Dorset
    Posts
    274
    I think you have a bit missing from your StrWhere. I would expect to see something like this:

    strWhere = "Hospital = '" & txtHospID.Text & "'"

  3. #3
    tracamonali is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    4
    SoftwareMatters, yes it worked!!!!!!!!!!!!!
    strWhere = "[Hospital#] = '" & Me.txtHospID & "'"

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Open a form on 90% Zoom
    By rhutton7 in forum Forms
    Replies: 0
    Last Post: 07-01-2009, 09:53 PM
  2. In a field on a Form, on click open another form
    By jackieagra in forum Programming
    Replies: 1
    Last Post: 03-20-2008, 09:44 AM
  3. Form will not open
    By dserbanescu in forum Forms
    Replies: 0
    Last Post: 01-09-2008, 09:48 AM
  4. Using combo box to open another form
    By ladyairj23 in forum Forms
    Replies: 0
    Last Post: 06-02-2006, 07:03 AM
  5. Open a form from a web page
    By Karyn-2000 in forum Programming
    Replies: 0
    Last Post: 04-21-2006, 07:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums