Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    justinwright is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    104

    Populating attachment field based on text box

    Thanks to pbaldy, I solved the first part of the problem here:



    https://www.accessforums.net/forms/p...-box-8073.html

    Lets say you have four text boxes and one attachment field on your form
    One number data type (in table), we'll call it LookupNumber
    Second is a number, ReturnNumber
    Third is a date, ReturnDate
    Fourth is text, ReturnText
    Fifth is an attachment field

    I am able to have the user specify the lookup number and look up the values with the following code:

    Code:
    Dim db As DAO.Database 
    Dim rs As DAO.Recordset 
    
    Set db = CurrentDb 
    Set rs = db.OpenRecordset("Select * FROM TrackingTable WHERE [LookupNumber] = " & Me.[txtLookupNumber])
    And then using code like:

    Code:
    Me.txtReturnNumber = Nz(rs!ReturnNumber, "")
    My question is, how would I populate an attachment field like that?

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    What sort of attachment are you trying to put "in" the attachment field?

  3. #3
    justinwright is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    104
    Most likely the attachment will be either a txt or PDF file (most of the time PDF file of a scanned document). I can require them to just use PDF if that would make it easier.

    I have it adding to the attachment field (seperate input form), but I just need something to list said attachments on the look up form, and provide a way for them to double click and open it (the attachments are stored in the attachment field inside the same db).

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I'm afraid I am with PBaldy on this one in that I have never used these attachment fields before and so have no 1st hand knowledge to share. I also use the last link Paul supplied to let the user select the file. I guess a screen capture of your Lookup Form might be useful for me to get a better idea what you are up against. You have the attachment in the AttachmentField but don't have a description of it for your form? Is that right?

  5. #5
    justinwright is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    104
    Correct, I only have an attachment field on the form thats currently bound to the AttachmentField field in the db (and I know they have to be unbound for it to look up).

    Attached is a SS of the form.

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    What would you like to see on the form you've shown and in what control?

  7. #7
    justinwright is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    104
    In the Check # part I want them to be able to type in a number, click the lookup button, and it return the list of attachments (that control on the form is an Attachment control). It already looks up and populates everything else, that's just the last part that I have left.

    I want them to be able to list the attachments and double click them to open them if desired.

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Are you saying that the Check # has a 1:m relationship with the attachments? That would put the Attachment field in another table with a ForeignKey.

  9. #9
    justinwright is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    104
    Uh, I didn't understand much of that ._.

    The check number is a field in the DB (but the DB itself has no primary key, I thought about making the check # the primary key but idk what that would do to other things). It just looks up the rest of the fields by the check number (the check number is the first field in the DB).

    The attachment field is in the same table, at the end.

  10. #10
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    How many attachments can each record have?

  11. #11
    justinwright is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    104
    Ideally I'd like up to three, as many as 5 if I could

  12. #12
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I really think you should consider another table for the attachments with a ForeignKey field that points to the 1 side of the relationship. Then you would display these Attachments in a SubForm in Continuous Form view.

  13. #13
    justinwright is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    104
    Do you have a guide or anything handy? That's frankly all Greek to me (I'm still really new at this).

  14. #14
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Have you looked at any of the templates that come with Access for ideas and how thay did it? Most of them have a mainForm/SubForm for something that displays a 1 to many relationship.

  15. #15
    justinwright is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    104
    Oh, I didn't even think about that. I'll look at it and get back to you on things, thanks

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 15
    Last Post: 09-18-2010, 01:19 PM
  2. Replies: 3
    Last Post: 06-29-2010, 12:08 PM
  3. Replies: 0
    Last Post: 05-14-2010, 07:28 AM
  4. Replies: 2
    Last Post: 05-05-2010, 02:52 PM
  5. Populating a "Text" field in a Report
    By two_smooth in forum Reports
    Replies: 20
    Last Post: 02-19-2010, 11:25 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