Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    N1755L's Avatar
    N1755L is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Toronto, Ontario
    Posts
    27

    #Type! error driving me crazy!

    Sorry guys/gals,



    Been Googling hours on end, can't find any solution. It must be something fairly simple, but I've been trying everything, for over 4 straight hours now, and I can't get rid of this #Type! foolishness.

    I'm attaching the database, hope someone can easily see the problem.

    The form in question is frmAutoModels. I have a dlookup textbox that I want to reference the tblEngineSizes table.

    Basically, there's a possibility that the engine size might be entered into the form as a letter (W, for example), so in the event that the engine size is entered as a letter, then the lookup textbox, just to the right of the W-entered engine size, will display the actual engine size (1.8L, for example).

    Simple, right?

    Maybe I'm going about it all wrong, maybe I should be using a different method to detect that letter input in the engine size field, and a different method as well to retrieve the engine size that corresponds to the letter that's input?

    Bit novice to Access, seems that the answer for everything is to get info from a query, if this is such a case again, hopefully someone can explain how I would go about accomplishing that in this instance.

    Thanks in advance.
    Attached Files Attached Files

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    I run v2007 and so cannot open a v2010 file. If your question is not version-specific (and this one isn't) you're always better off saving a copy of your file in 2003 format before attaching/posting it here...that way more people are able to download and look at it.

    Can you post the DLookup() code you're attempting to use?

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    This is the Dlookup

    =DLookUp("[fEngineSize]","tblEngineSizes","[fEngineCode] = " & [Forms]![frmAutoModels]![Engine_Size])

    There is a problem with the following expression. It refers to a control on the same form. Going to see if I can bind a new control to replace.

    =[Forms]![frmAutoModels]![sfrmAutoModels]![Engine_Size]

    I clicked around and changed a bunch of stuff. I was thinking corrupt module at first. I am going to start again.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    What is the relationship between tblAutomodels and tblEngineSizes? You need to create a join between these two tables and base your subform off of that.

    The whole
    =[Forms]![frmAutoModels]![sfrmAutoModels]![Engine_Size]
    makes no sense to me whatsoever. If, somehow, you got this to work in a continuous form, all it would do is display the value for field fEngineSize and you already have a control bound to fEngineSize. It is named EngineSize.

  5. #5
    N1755L's Avatar
    N1755L is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Toronto, Ontario
    Posts
    27
    Sorry, when I try "Save Database As", it doesn't offer me any other options to save it in any other version... ?


    Quote Originally Posted by Missinglinq View Post
    I run v2007 and so cannot open a v2010 file. If your question is not version-specific (and this one isn't) you're always better off saving a copy of your file in 2003 format before attaching/posting it here...that way more people are able to download and look at it.

    Can you post the DLookup() code you're attempting to use?

    Linq ;0)>

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Here you go linq. One form was not saved during the conversion. I do not believe the conversion affected the issue at hand. Beware Control Names do not match field names for Control Sources.
    Attached Files Attached Files

  7. #7
    N1755L's Avatar
    N1755L is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Toronto, Ontario
    Posts
    27
    Quote Originally Posted by ItsMe View Post
    =[Forms]![frmAutoModels]![sfrmAutoModels]![Engine_Size]
    The subform part here was just desperation... I was trying everything... I've changed the quotation marks a million times, along with the square brackets, and even fooled around with single quotes, as there appears to be some in the following I found elsewhere:

    *****

    Re: DLookup type mismatch error


    Remove the items in red:

    Me.Fund_1 = DLookup("[Fund#]", "TradeFundInfo", "[FundName]='" & Me.FromFund1 & "'" And "[Product]='" & Me.ProductCombo & "'")


    *****

    I spent hours a while back with a dlookup 'cause the examples I was trying to implement were just slightly different placement of quotation marks or square brackets (so many different past versions, example code in Googled forum posts are sometimes dodgy propositions).

  8. #8
    N1755L's Avatar
    N1755L is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Toronto, Ontario
    Posts
    27
    Hmmm... When I input "W" for engine size (third column of the frmAutoModels form), the dlookup should find that corresponding "W" in the tblEngineSizes table, and return the corresponding "1.8L" value in that dlookup textbox control (4th column)... btw, why is it that when I resize or move the controls in Design mode, they do not move/change accordingly in the View mode?).

    But now I'm belatedly starting to realize that if I do not input a letter in the 3rd column that corresponds to a letter in the tblEngineSizes table, then there is no match in the lookup... no, wait... no, that can't be the problem, as I was going down this line of thought, I decided to change all the inputs to letters M and W, but still the same error, so that's not the problem.

    Why "#Type!"?

    Guess I have to go a different route than a dlookup? How do I get the form to check whether or not a user has input an engine size in the form of a letter, and then have a textbox to the right show the engine size that corresponds to the letter that was input?

    Yeah, dlookup is never going to work for this purpose, is it? How else to do this?


    Thanks.
    Last edited by N1755L; 04-29-2014 at 05:59 PM. Reason: Just added an extra 2 lines, nothing fancy.

  9. #9
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    If the Field in question is defined as Text, as the 'W' implies, the correct syntax would need to be

    =DLookup("FieldToLookUp", "TableName", "[FieldName] = '" & Me.ControlNameOnForm & "'")

    The syntax you originally used is only valid for a Field defined as a Number.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  10. #10
    N1755L's Avatar
    N1755L is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Toronto, Ontario
    Posts
    27
    I also tried to code VBA so as to open the tblEngineSizes table as a recordset, and then try to compare the value than was input into the 3rd column of the frmAutoModels form, so I could say "If you look at the value input into the 3rd column of the frmAutoModels form, and compare it to the recordset's fEngineCode field and find a match, return the value in the recordset's corresponding fEngineSize field". So, entering a "W" in the 3rd column of the form, would return a "1.8L" value, and entering a "R" would return "1.6L", etc.

    I couldn't figure out how to make the code work, but was I on a fool's errand anyway, trying to use this method? Or might this method be a good way to go, provided I can figure out how to code it?

  11. #11
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Domain aggregates can be slow. As ItsMe suggested and I agree, make the RecordSource of subform a query.

    SELECT tblAutoModels.*, tblEngineSizes.fEngineSize FROM tblEngineSizes RIGHT JOIN tblAutoModels ON tblEngineSizes.fEngineCode = tblAutoModels.fEngineSize;

    Then bind textbox to fEngineSize and set it as Locked Yes, TabStop No.

    No DLookup is needed.


    tblEngineSizes does not have primary key set. Since you are saving the fEngineCode value into tblAutoModels, set it as primary key and the fESID field can go away.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  12. #12
    N1755L's Avatar
    N1755L is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Toronto, Ontario
    Posts
    27
    Interesting! So here we are again with the single and double quotes again... lemme try that.

    Darned! Same #Type! crappola again... tried the following as per your suggestion:

    =DLookUp("[fEngineSize]","tblEngineSizes","[fEngineCode] = '" & [Forms]![frmAutoModels]![txtEngineSize] & "'")

    Notice I finally changed the control name to "txtEngineSize", instead of "Engine Size" (for some strange reason, when I'd tried to change it this way earlier, the textbox would stop displaying data, so I'd left it alone as "Engine Size", but now I've managed to change it).

    Still getting that "#Type!" foolishness... I must be on the wrong track... there must be a better way... no?



    Quote Originally Posted by Missinglinq View Post
    If the Field in question is defined as Text, as the 'W' implies, the correct syntax would need to be

    =DLookup("FieldToLookUp", "TableName", "[FieldName] = '" & Me.ControlNameOnForm & "'")

    The syntax you originally used is only valid for a Field defined as a Number.

    Linq ;0)>

  13. #13
    N1755L's Avatar
    N1755L is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Toronto, Ontario
    Posts
    27
    Quote Originally Posted by June7 View Post
    Domain aggregates can be slow. As ItsMe suggested and I agree, make the RecordSource of subform a query.

    SELECT tblAutoModels.*, tblEngineSizes.fEngineSize FROM tblEngineSizes RIGHT JOIN tblAutoModels ON tblEngineSizes.fEngineCode = tblAutoModels.fEngineSize;

    Then bind textbox to fEngineSize and set it as Locked Yes, TabStop No.

    No DLookup is needed.


    tblEngineSizes does not have primary key set. Since you are saving the fEngineCode value into tblAutoModels, set it as primary key and the fESID field can go away.

    Hello June7,

    As per your suggestion, I created that query and it works a charm! Now I created a textbox (Text15) to experiment with retrieving the tblEngineSizes.fEngineSize column from that query, so as to see this value in the Text15 box on the form, but it's not working, I tried using the Expression Builder to point directly to that column within the query, but nothing is working, I can't get that query tblEngineSizes.fEngineSize column to show on my frmAutoModels form (constant #Name! error). So close! AAAARRRRGGGGHHHH!!!! MS can be sooooo maddening!

    Such a simple little thing, been at it almost 7 hrs. now...

  14. #14
    N1755L's Avatar
    N1755L is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Toronto, Ontario
    Posts
    27
    Thanks Linq, but if I can get this to work without use of a dlookup, I think I'll be doing myself favors... I just didn't know how to do it by way of queries, but think that this is likely the preferred method.

    Quote Originally Posted by Missinglinq View Post
    If the Field in question is defined as Text, as the 'W' implies, the correct syntax would need to be

    =DLookup("FieldToLookUp", "TableName", "[FieldName] = '" & Me.ControlNameOnForm & "'")

    The syntax you originally used is only valid for a Field defined as a Number.

    Linq ;0)>

  15. #15
    N1755L's Avatar
    N1755L is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Toronto, Ontario
    Posts
    27
    Blimey! How do I upload the updated database?

    Should I start a new "How to reference a query field/column on my form?" topic/thread?
    Last edited by N1755L; 04-29-2014 at 07:53 PM. Reason: Added "/thread".

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

Similar Threads

  1. Dlookup driving me crazy
    By NJMike64 in forum Modules
    Replies: 3
    Last Post: 04-19-2014, 01:58 PM
  2. Too few arguments is driving me crazy....
    By Spidee in forum Access
    Replies: 3
    Last Post: 07-10-2013, 07:41 AM
  3. I know it's easy but it's driving me crazy!!!
    By pensived in forum Queries
    Replies: 1
    Last Post: 02-22-2012, 02:55 AM
  4. ShipToCode is driving me crazy
    By Accessgrasshopper in forum Access
    Replies: 7
    Last Post: 02-26-2011, 04:55 PM
  5. Report issue driving me crazy
    By Grofica in forum Reports
    Replies: 11
    Last Post: 01-28-2011, 11:23 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