Results 1 to 5 of 5

Thread: Access and Dymo

  1. #1
    Join Date
    Aug 2009
    Posts
    3

    Unanswered: Access and Dymo

    I have built a mini access database that will allow users to print shipping labels directly from the form by selecting a label type and hitting a print button that will copy the info from the access form to the dymo label. However I want a barcode on the label and the problem I am running into is that the label does not save and I have a Destroy OLE objects code posted below. I want to leave this code in, but somehow want the label to save after it clears out the contents so that the counter on the barcode keeps increasing by one on the Dymo Label Program. Is there something easy to input into this code that will tell the Dymo program to save the label?


    Code:
    Function DestroyOLEObjects()
        '*********************************s*******************************************
        'This function destroys OLE object
                On Error Resume Next
        Set DymoAddIn = Nothing
        Set DymoLabels = Nothing
        
    End Function

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Why don't you work totally in Access? Create a report with the proper format for the labels you want to print and associate the Dymo printer to it. That way you would be able to keep the count of printed labels into Access.

    Have a nice day!

  3. #3
    Join Date
    Aug 2009
    Posts
    3
    If there was a way to create a Random number each time the user clicks the print button on access that would be fine to. I need that number to change each time and not contain decimals.

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    For the random number:

    1) Create a table:
    Name: Tbl_RandomNumbers
    Column1: Name: RandomValue, Data Type: AutoNumber (New values:Random), Primary key
    Column2: Name: TimeStamp, Data type: String (Length: 32), Indexed no duplicates

    2) Place the following code into an independant module:
    Code:
    Private Declare Function GetTickCount Lib "kernel32" () As Long
    Function GetRandomNumber() As Long
    
        Dim strTimeStamp As String
        
        strTimeStamp = Now & GetTickCount
        CurrentDb.Execute "INSERT INTO Tbl_RandomNumbers ( [TimeStamp] ) SELECT '" & strTimeStamp & "' AS Expr1;"
        GetRandomNumber = DLookup("RandomValue", "Tbl_RandomNumbers", "TimeStamp = '" & strTimeStamp & "'")
        CurrentDb.Execute "DELETE * FROM Tbl_RandomNumbers"
        
    End Function
    Another solution could be:
    Code:
    Function GetRandomNumber() As Double
    
        GetRandomNumber = CDbl(Replace(CStr(CDbl(Now)) & CStr(GetTickCount), ",", ""))
        
    End Function
    Have a nice day!

  5. #5
    Join Date
    Aug 2009
    Posts
    3
    I went with this line of code and it works great except for one problem. Each time I open the database and the user prints a label...It starts at the same number it did when the database last closed. I cannot seem to get the number to change if you close and then reopen the program. Any ideas?

    Code:
    Forms![Main]!Text143.Value = 1 + Int(100000 * Rnd())

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •