VB compile error User defined Object

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32661

    #16
    Originally posted by alpnz
    By that I presume, "Is there a Query in the query window of the database called 'qry_elabel'?, the answer is yes, but that is a good question, because if I select 'crtl' 'space' at each step as I type in the objects, I would have expected the queries to have shown up, under say "DoCmd.OpenQuer y "should show up in the object list at this point" ??? ..
    JS
    No it wouldn't.
    This gets a little complicated but it's only where the interpreter recognizes properties of an object. Collections don't get shown. It's all about what the interpreter can know at that time.

    Comment

    • MMcCarthy
      Recognized Expert MVP
      • Aug 2006
      • 14387

      #17
      Originally posted by NeoPa
      No it wouldn't.
      This gets a little complicated but it's only where the interpreter recognizes properties of an object. Collections don't get shown. It's all about what the interpreter can know at that time.
      Still for some reason the database is not recognising the query as a valid object when it is being called by the open recordset action. The first thing to check is the obvious. Is the spelling of the query name correct, does it have any capitalisation, spaces, underscores, etc.?

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32661

        #18
        Am I off course in Post #15 then Mary?
        Or am I just out of step with which post you're referring to?
        I get confused :(

        Comment

        • MMcCarthy
          Recognized Expert MVP
          • Aug 2006
          • 14387

          #19
          Originally posted by NeoPa
          Am I off course in Post #15 then Mary?
          Or am I just out of step with which post you're referring to?
          I get confused :(
          This is what I though as well put then this was posted ...

          By that I presume, "Is there a Query in the query window of the database called 'qry_elabel'?, the answer is yes, ...
          So now we need to find out why the vba won't recognise it.

          John, I just had a thought (Oh! my brain hurts!)

          Check the references list in the Tools menu. Make sure there is a Microsoft DAO library ticked on the list.

          Mary

          Comment

          • alpnz
            New Member
            • Nov 2006
            • 113

            #20
            Thats a good question, I am not on the M$ box, so will have pop into the office and crank it up ... BUT
            Something I have checked over and over is,
            The spelling of the query and the 5-6 different ways of defining the query as a recordset.
            I have provided text as the variables, and the label prints, so it is definately the definition of the data source. The query works if opened in the database window, (and I supply the criteria for the [PakTrakID])

            The query consolidates text values for label lines, from about 4-5 tables.
            I was driving for about 5 hours today, and I had an inspiration. One of the variables consolidated is 3 numbers into one to make up the EAN number for the bar code ... do you get it yet "number", I am about to Dim var4 As an Integer ... this might make a huge difference.

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32661

              #21
              Let us know how you get on with that :)

              Comment

              • alpnz
                New Member
                • Nov 2006
                • 113

                #22
                So what was the outcome. Well after being buried in another project and not having time to dilly about on this, I finally sat down and had another go tonight. And you guessed it, I got it to work. Essentially I eliminated the obvious. and defined the data in the simplistic manner below.
                Code:
                'A sub routine to print directly to thermal printers with their own language set
                Private Sub create_eplab_Click()
                ' First sort out the variables. Including label content, quantity to print etc
                	Const quote As String = """"
                	
                	Dim var1 As String
                	Dim var2 As String
                	Dim var3 As String
                	Dim var4 As String
                	Dim var5 As String
                	Dim qty As Integer
                ' Sort out where the data is coming from. Aim for reusable code
                ' Declare the variable data values. It assumes we have a simple query which deals with
                ' consolidating data from various tables into lines of text and values.
                
                	var1 = DLookup("[gr]", "qy_elabel")
                	var2 = DLookup("[pr]", "qy_elabel")
                	var3 = DLookup("[sz]", "qy_elabel")
                	var4 = DLookup("[EAN]", "qy_elabel")
                	var5 = DLookup("[rp]", "qy_elabel")
                	qty = Int(InputBox("How many labels for the selected line do you wish to print?", "Number of Labels"))
                	
                ' Code each label combination required. This is where the Printer centric language is dealt with. EPL Or ZPL or Birch, etc etc.
                	
                
                	Dim lab1 As String
                	
                lab1 = "N" & vbCrLf _
                		& "S4" & vbCrLf _
                		& "A30,30,0,4,1,1,N," & quote & [var1] & quote & vbCrLf _
                		& "A30,150,0,4,2,2,N," & quote & [var2] & quote & vbCrLf _
                		& "A30,225,0,4,2,2,N," & quote & [var3] & quote & vbCrLf _
                		& "B30,300,0,E30,2,4,150,B," & quote & [var4] & quote & vbCrLf _
                		& "A400,400,0,4,1,1,N," & quote & [var5] & quote & vbCrLf _
                		& "P" & [qty] & vbCrLf
                		
                		
                		
                ' Print the label to the printer.
                
                Open "COM2:" For Output As #1
                	   Print #1, lab1
                		
                Close #1
                
                End Sub
                I reproduce it for all that may have an interest for EFTPOS and till printers, You can of course enter Esc ASCII sequences to open cash draws etc. Hope it might help in the future.

                John S

                Comment

                • NeoPa
                  Recognized Expert Moderator MVP
                  • Oct 2006
                  • 32661

                  #23
                  Thanks for posting that John.
                  We always prefer resolutions to be posted where possible. Many of the hits we get are from non-members looking for pre-packaged answers to their problems. This is a perfectly answered problem so will be useful.
                  PS Senior Member after two more posts ;)

                  Comment

                  Working...