Page 2 of 2 FirstFirst 12
Results 16 to 20 of 20
  1. #16
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,525

    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  2. #17
    mejia.j88 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Nov 2011
    Location
    california
    Posts
    228
    actually, one more question:

    I'm reviewing the code to make sure i fully understand it (it was made by a former coworker).
    i dont quite understand the
    "[ID]=" &
    pRecID ​from the printlabels() code
    DoCmd.OpenReport "rpt_leadbond_yield_label", acViewPreview, , "[ID]=" & pRecID

  3. #18
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,525
    The wherecondition argument of OpenReport is an SQL "WHERE" clause without the word "WHERE". If you wanted to run the report for ID 123 it would look like

    "ID = 123"

    Since you want to use a dynamic value for the ID, you concatenate the fixed part ("ID=") with the dynamic part (your variable containing the desired ID).
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #19
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    In your original code, when you called thePrintLabels function, the record to be printed had to be the current record.

    I added a parameter, so that the PrintLabels function didn't have to rely on finding or being on the correct record to get the record ID value; the value (ID) was passed to the function.

    In Access, the autonumber value for ID is populated after the .ADDNEW command is executed. In SQL server, it is not populated until the record is actually saved. Which is why my method wouldn't work for linked SQL tables as it is currently written.

    I pass the ID to the PrintLabels function, instead of relying on the correct record being selected before printing. Same result, different methods.

    I should start using Paul's example if getting to ID ....

  5. #20
    mejia.j88 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Nov 2011
    Location
    california
    Posts
    228
    man,
    you guys are good.
    thanks!

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

Similar Threads

  1. Replies: 1
    Last Post: 10-25-2011, 09:47 PM
  2. VBA Code not working how it Should
    By Juan4412 in forum Programming
    Replies: 7
    Last Post: 12-07-2010, 01:59 PM
  3. VBA Code Not working
    By jo15765 in forum Programming
    Replies: 12
    Last Post: 12-03-2010, 04:01 PM
  4. VB code not working
    By cwwaicw311 in forum Programming
    Replies: 17
    Last Post: 04-26-2010, 07:02 PM
  5. VBA Code for working with IE
    By smikkelsen in forum Programming
    Replies: 3
    Last Post: 04-15-2010, 01:05 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