Results 1 to 14 of 14
  1. #1
    Behrooz is offline Novice
    Windows XP Access 2013 32bit
    Join Date
    Feb 2019
    Posts
    26

    Display Inputmask in dlookup

    Hello


    When using DLOOKUP with combined fields. How can I display the fields Mask

    Dlookup("field1","&msg&","field2","tblName","id=" & me.id)

    Sent from my SM-J701F using Tapatalk

  2. #2
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,641
    Does that even work?
    DLookup has 3 arguments - Field, Table, and Criteria.

  3. #3
    Behrooz is offline Novice
    Windows XP Access 2013 32bit
    Join Date
    Feb 2019
    Posts
    26
    Quote Originally Posted by moke123 View Post
    Does that even work?
    DLookup has 3 arguments - Field, Table, and Criteria.
    No, with this form, maybe with a little change in the first part
    ("FieldNam &"msg"&",tblName,"id=" &me.id)

    Sent from my SM-J701F using Tapatalk

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    that still won't work

    you want something like

    Dlookup("[LookupField]", "tblTableName", "[Field1] = " & NumberValue & " AND [Field2] = '" & TextValue & "'")

    in this example I've showed you how to look up both a number and a text value, note text values need to be enclosed in ' or " marks, but if you use " marks you'll need to double them up

    Dlookup("[LookupField]", "tblTableName", "[Field1] = " & NumberValue & " AND [Field2] = """ & TextValue & """")

  5. #5
    Behrooz is offline Novice
    Windows XP Access 2013 32bit
    Join Date
    Feb 2019
    Posts
    26
    Quote Originally Posted by rpeare View Post
    that still won't work

    you want something like

    Dlookup("[LookupField]", "tblTableName", "[Field1] = " & NumberValue & " AND [Field2] = '" & TextValue & "'")

    in this example I've showed you how to look up both a number and a text value, note text values need to be enclosed in ' or " marks, but if you use " marks you'll need to double them up

    Dlookup("[LookupField]", "tblTableName", "[Field1] = " & NumberValue & " AND [Field2] = """ & TextValue & """")
    Thank you. Now in this statement, how to display the Inputmask field

    Sent from my SM-J701F using Tapatalk

  6. #6
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,641
    Not sure what your trying to accomplish with an input mask and a dlookup.
    An input mask is used to guide input into a field.

    Are you trying to format the output? What type of data are you working with? What is msg?
    What should the output look like?

  7. #7
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    format(Dlookup("[LookupField]", "tblTableName", "[Field1] = " & NumberValue & " AND [Field2] = '" & TextValue & "'"), "FORMAT NAME HERE")

  8. #8
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    in response to moke123, dlookup removes formatting, for instance a dlookup on a currency field would remove the currency symbol, which means you have to re-insert the formatting as necessary. Dlookup also tends to make everything a text field or be evaluated as a text field which isn't always what you want.

  9. #9
    Behrooz is offline Novice
    Windows XP Access 2013 32bit
    Join Date
    Feb 2019
    Posts
    26
    Quote Originally Posted by rpeare View Post
    in response to moke123, dlookup removes formatting, for instance a dlookup on a currency field would remove the currency symbol, which means you have to re-insert the formatting as necessary. Dlookup also tends to make everything a text field or be evaluated as a text field which isn't always what you want.
    Okay.You are right but Sometimes it is necessary to bring two or more fields to a single-textbox, how to display an extension of one of the fields that are inputmask

    Sent from my SM-J701F using Tapatalk

  10. #10
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    not a clue what you're asking with your last post. Perhaps if you post an example of what your data looks like and what you want your result to be.

  11. #11
    Behrooz is offline Novice
    Windows XP Access 2013 32bit
    Join Date
    Feb 2019
    Posts
    26
    Quote Originally Posted by rpeare View Post
    not a clue what you're asking with your last post. Perhaps if you post an example of what your data looks like and what you want your result to be.
    Excuse me, I do not have access to the computer now, so I can not post exactly the phrase for you, I put fields in the combination by DLOOKUP in a single screen, but I could not display the format of one of the fields that was inputmask

    Sent from my SM-J701F using Tapatalk

  12. #12
    Behrooz is offline Novice
    Windows XP Access 2013 32bit
    Join Date
    Feb 2019
    Posts
    26
    Quote Originally Posted by Behrooz View Post
    Excuse me, I do not have access to the computer now, so I can not post exactly the phrase for you, I put fields in the combination by DLOOKUP in a single screen, but I could not display the format of one of the fields that was inputmask

    Sent from my SM-J701F using Tapatalk
    Inside the MobileNo Field in the Table. there is some Signs (input mask). I am going to display them in theTextBox

    MyTxtBox= DLookup("[Name] &"" "" & [MobileNo]", "tblEmployee", "[EmployeeID]=" & Me.EmployeeID)*


    Sent from my SM-J701F using Tapatalk

  13. #13
    Behrooz is offline Novice
    Windows XP Access 2013 32bit
    Join Date
    Feb 2019
    Posts
    26
    Quote Originally Posted by Behrooz View Post
    Excuse me, I do not have access to the computer now, so I can not post exactly the phrase for you, I put fields in the combination by DLOOKUP in a single screen, but I could not display the format of one of the fields that was inputmask

    Sent from my SM-J701F using Tapatalk
    Inside the MobileNo Field in the Table. there is some Signs (input mask). I am going to display them in theTextBox

    MyTxtBox= DLookup("[Name] &"" "" & [MobileNo]", "tblEmployee", "[EmployeeID]=" & Me.EmployeeID)

    Sent from my SM-J701F using Tapatalk

  14. #14
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,641
    I think I understand. If you use the input mask wizard it gives you the option to store the mask characters - ie. (___)___-____ in the table.
    to get the name and phone number in a field you would concatenate them
    Note that Name is a reserved word and you should not use it as a field name.

    try

    Code:
    MyTxtBox= DLookup("[Name]", "tblEmployee", "[EmployeeID]= " & Me.EmployeeID) & " " &  DLookup("[MobileNo]", "tblEmployee", "[EmployeeID]= " & Me.EmployeeID)
    Last edited by moke123; 05-23-2019 at 04:17 PM.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. VBA inputmask
    By erandalln in forum Programming
    Replies: 4
    Last Post: 04-14-2017, 12:03 PM
  2. Replies: 9
    Last Post: 04-18-2014, 08:51 PM
  3. Replies: 4
    Last Post: 07-15-2012, 01:48 PM
  4. Replies: 6
    Last Post: 10-20-2011, 11:27 AM
  5. InputMask yyyy-mm for Label
    By smaky in forum Queries
    Replies: 5
    Last Post: 11-03-2010, 10:20 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