+ Reply to Thread
Results 1 to 14 of 14

Dount VBA code producing Run-time error '3075'

  1. #1
    Valued Forum Contributor
    Join Date
    01-10-2011
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    317

    Dount VBA code producing Run-time error '3075'

    Hi,

    I am trying to build a bit of code which will search and go to a record in the form Boxes. It shoudl first check to see if the number is valid in the table and then go to that record in the form. The code below keeps producing an error on the line highlighted, it displays the error "Run-time error '3075': Syntax error (missing operator) in expression 'count(Box Number)'."

    Please Login or Register  to view this content.

    Does anyone know why I keep getting this message? Have I missed out a bit of code? or is the dcount function wrong?

    Thank you in advance

    Jeskit
    Last edited by jeskit; 07-16-2012 at 07:25 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    01-10-2011
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Dount VBA code producing Run-time error '3075'

    Hi,

    I seemed to have fixed the problem. I added [] around Box Number in the Dcount function line.

    However when I fixed that line it produced a different problem. with the line
    Please Login or Register  to view this content.
    . it produces the error "Run-time error '2498': An expression you entered is the wrong data type for one of the arguments"

    Does anyone know what this error means?

  3. #3
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Dount VBA code producing Run-time error '3075'

    What is the value of Ref?
    Remember what the dormouse said
    Feed your head

  4. #4
    Valued Forum Contributor
    Join Date
    01-10-2011
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Dount VBA code producing Run-time error '3075'

    Thanks for replying

    ref is a integer value which is the Me.Text4.Value

  5. #5
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Dount VBA code producing Run-time error '3075'

    Um, yeah - I can read. I mean what is the actual value when you run the code and is that a valid record number?

  6. #6
    Valued Forum Contributor
    Join Date
    01-10-2011
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Dount VBA code producing Run-time error '3075'

    sorry I misunderstood what you meant. The value is valid number in the table.

  7. #7
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Dount VBA code producing Run-time error '3075'

    Quote Originally Posted by jeskit View Post
    The value is valid number in the table.
    Meaning what exactly?

  8. #8
    Valued Forum Contributor
    Join Date
    01-10-2011
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Dount VBA code producing Run-time error '3075'

    Ok the table has box number as its primary key column. However the number 2 into text4 then it wont be record 2 it would be box number 2 which could be for example record number 7 in the table. Does this make sense? So I need code which will first find out the record number which has a box number of whatever is in ref and then open the record in the Boxes form.

  9. #9
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Dount VBA code producing Run-time error '3075'

    Quote Originally Posted by jeskit View Post
    Does this make sense?
    Not to me in the context of what you have posted. Why don't you just open the form using a filter for the box number you want?

  10. #10
    Valued Forum Contributor
    Join Date
    01-10-2011
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Dount VBA code producing Run-time error '3075'

    Ok, I tried doing it so it would open the form using a filter however it still didn't go to the correct record it just went to the first record.
    Please Login or Register  to view this content.

  11. #11
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Dount VBA code producing Run-time error '3075'

    Please Login or Register  to view this content.
    rather than
    Please Login or Register  to view this content.

  12. #12
    Valued Forum Contributor
    Join Date
    01-10-2011
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Dount VBA code producing Run-time error '3075'

    Thats great it works, however when its filtered you can not then browse through the other records

  13. #13
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Dount VBA code producing Run-time error '3075'

    Well, you can just clear the filter. Alternatively, you could revise your original code to something like
    Please Login or Register  to view this content.

  14. #14
    Valued Forum Contributor
    Join Date
    01-10-2011
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Dount VBA code producing Run-time error '3075'

    thank you sooooooo much for all your help works perfectly!!! Thank you!!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1