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?
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?
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
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
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.
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 usedto grab the email from that form and use it. Thanks for the help.Code:.to = Me.Email