Results 1 to 5 of 5
  1. #1
    xduy is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Jan 2017
    Posts
    6

    Question How to use a form to display records?


    Hi everyone.

    I have a database with an ID field. I want to be able to type in the ID and have all of the information show up in a form. Can I do this with a form? How should I do this?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    make a continuous form to show all records,
    put a text box in the header, txtFind
    enter ID and it will filter that record. If it shows ,it exists, else it does not.
    put a button in the header to show the detail single record form of the record selected.
    open it using the button click code:
    Code:
    sub btnDetail_click()
      openform "frmDetail" ,,,"[id]=" & me.ID
    end suib

    here is the code to filter the id in the text box
    Code:
    sub txtFind_afterupdate()
    if isNull(txtFind) then
       me.filterOn = false
    else
       me.filter = "[id]=" & me.txtID
       me.filterOn = true
    endif
    end sub

  3. #3
    xduy is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Jan 2017
    Posts
    6
    I think I am tackling a bigger issue the wrong way here. My main goal is to be able to enter an ID and have a button that will send an email to the email associated with that ID. I think using a form here might be an extra step. I actually have the code written for the email done except for the part where I find out where to send it (by using the ID). The email does not have to be shown on the screen in any way if I can get it to it somehow in the code. Any ideas?

    Code:
    Function sendReportFinish()
        ' JUMP TO THE ERRHANDLER LABEL IF THERE IS AN ERROR
        On Error GoTo ErrHandler
        
        ' SET OUTLOOK AS THE OBJECT THAT WILL BE USED
        Dim objOutlook As Object
        Set objOutlook = CreateObject("Outlook.Application")
        
        
        
        ' CREATE THE EMAIL OBJECT USING OUTLOOK
        Dim objEmail As Object
        Set objEmail = objOutlook.CreateItem(olMailItem)
        
        
        ' SET UP THE DETAILS OF THE EMAIL OBJECT
        With objEmail
            ' WHO TO SEND THE EMAIL TO
            '.to = ????????????????????
            
            ' CONTENT OF THE SUBJECT LINE
            .Subject = "Your part in the tool room is finished"
            
            ' CONTENT OF THE BODY USING HTML
            ' <br> IS THE NEWLINE CHARACTER
            .htmlBody = "Maintenance on the part you sent to the tool room is done. <br>" _
                    & "Check the attachment to see everything that was done to it." _
                    & "<br> <br> <br> <br>"
                    
            ' ATTACHES THE DOCUMENT TO THE EMAIL USING ITS LOCATION
            .Attachments.Add ("C:\Users\--------\Documents\rptPerformanceTimelinerpt.pdf")
            
            ' DISPLAYS THE EMAIL IN OUTLOOK BEFORE SENDING
            ' COMMENT OUT IF YOU DO NOT WANT TO SEE THE OUTLOOK WINDOW
            .Display
            
            
            ' SENDS THE EMAIL THAT THIS CODE CREATES WITHOUT PROMPT
            ' AN EMAIL CAN BE SENT WITHOUT DISPLAYING ANYTHING
            ' COMMENT OUT IF YOU WANT TO SEE THE EMAIL IN THE OUTLOOK WINDOW
            '.Send
        End With
        
        ' CLEAR VARIABLES
        Set objEmail = Nothing
        Set objOutlook = Nothing
     
    ' RUN NO CODE AND END FUNCTION IF THERE IS AN ERROR
    ErrHandler:
    
    End Function

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    So how you do you envision being able to select the correct email address?
    You would have to hard code the email address, select an email address from a combo box or enter the email address into a text box.

  5. #5
    xduy is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Jan 2017
    Posts
    6
    I ended up using ranman's code to generate a continuous form that would display the email based on the ID after clicking a button. Then I used
    Code:
    .to = Me.Email
    to grab the email from that form and use it. Thanks for the help.

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

Similar Threads

  1. Counting Records to display on Form
    By Ekhart in forum Forms
    Replies: 1
    Last Post: 08-01-2016, 10:13 PM
  2. Replies: 8
    Last Post: 05-10-2015, 06:24 PM
  3. Replies: 10
    Last Post: 02-09-2012, 04:42 PM
  4. Replies: 11
    Last Post: 10-04-2011, 02:29 AM
  5. Display ALL records in a form?
    By evander in forum Forms
    Replies: 3
    Last Post: 07-15-2010, 07:59 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