Results 1 to 14 of 14
  1. #1
    CementCarver's Avatar
    CementCarver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Location
    Canada
    Posts
    231

    Input Box Bound to Expression


    I have an input box that display a number field which is bound to an expression =IIf(IsNull([SMLicence]),"","SM" & [SMLicence] & " -14")

    But I am not able to input any numbers into this field, since it's bound to this expression.

    Is there anyway that a number can be input, regardless if it has an expression or not?

    CementCarver

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Create a new text box to handle your User Input and then add the new control name/value to your aggregate expression.

  3. #3
    CementCarver's Avatar
    CementCarver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Location
    Canada
    Posts
    231
    ItsMe,

    Don't quite understand what you're saying... Is it possible for you to provide an example?

    =IIf(IsNull([SMLicence]),"","SM" & [SMLicence] & " -14")

    So, you'd place the new textbox control name inside the expression above?

    CementCarver

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    What is the name of the field that contains your expression? This field is displaying information as a result of your expression, ie SM True -14

    Are you trying to add additional information in this text box control?

  5. #5
    CementCarver's Avatar
    CementCarver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Location
    Canada
    Posts
    231
    I patch together the correct licence number in the format that my client has asked for. But in the column, there is only a 2x digit number. So, if the SMLicence is 10, the output should display SM10-14. All I want to do is allow the client to input a number in this existing field.

    CementCarver

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by CementCarver View Post
    All I want to do is allow the client to input a number in this existing field.

    CementCarver
    I understood everything in post # 5, except this part.

    What is the name of the control that has your expression?

    Do you want to incorporate the user input within the expression?

  7. #7
    CementCarver's Avatar
    CementCarver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Location
    Canada
    Posts
    231
    The name of the control is SelfMLicence and yes, it would like to incorporate an input into the expression.

    CC

  8. #8
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    You need to create another control to collect your user input. You also need a way to fire some code to update the field named SelfMLicence.

    Here is one way to go about it.

    Erase the expresion within SelfMLicence. It will now be unbound. Create another unbound textbox named txtAddInput.

    In the form's "Current" event place the following. I took the liberty to edit the original expresion to add a space after SM.

    Code:
    Dim strLicense As String
    strLicense = IIf(IsNull([SMLicence]), "", "SM " & [SMLicence] & " -14")
    Me.SelfMLicence.Value = strLicense
    In the new control's AfterUpdate event (the one named "txtAddInput") place the following

    Code:
    Dim strLicense As String
    If Not IsNull(Me.txtAddInput) Then
    strLicense = Me.txtAddInput & "_"
    Else
    strLicense = ""
    End If
    strLicense = strLicense & IIf(IsNull([SMLicence]), "", "SM " & [SMLicence] & " -14")
    Me.SelfMLicence.Value = strLicense
    With that, when the user exits the new text box, it will add whatever was typed into txtAddInput.

    Let me know if you need to change anything around, like the underscore.

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,913
    Why save concatenated data? Why save two discrete values into same field? Why save calculated value at all? Saving calculated data is usually ill-advised.

    Why save the SM and -14 into the field? If this is same for all records, can calculate concatenated value when needed for display.
    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.

  10. #10
    CementCarver's Avatar
    CementCarver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Location
    Canada
    Posts
    231
    Thanks ItsMe

    Your code worked perfectly. I can now have the client input the numerical value required.

    Because their old licencing system worked for the format required I needed a method to continue with their format is. Self Marketer Licence numbers are SM30-14, meaning the 30th licenced issued within the year 2014.

    Thank you for everyone's input.

    CementCarver

  11. #11
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Alright, as long as your client is happy. The code I gave you gives you two unbound text boxes. With the value's being held in a string variable you may not need both textboxes. But if you got things working to your liking......

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,913
    Okay, I can understand that, have similar situation (20yyA-XXXX). Then the -14 needs to be dynamic? I have code that determines the current year and uses that value to construct the identifier.
    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.

  13. #13
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by June7 View Post
    Okay, I can understand that, have similar situation (20yyA-XXXX). Then the -14 needs to be dynamic? I have code that determines the current year and uses that value to construct the identifier.
    Yeah, I think more can be done to remove the User interaction. Limit the chance for error because the user typed something incorrectly. Anytime there is a user input, there is a chance for error. The more the program dictates, the more consistent the data.

  14. #14
    CementCarver's Avatar
    CementCarver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Location
    Canada
    Posts
    231
    Gentlemen,

    When a new marketer gets created, I automatically assign the next highest value for the marketing licence number (M24 - 14), but for the self marketing number, not all marketers have this distinction, therefore, the user needs to assign it when the time comes. Or else I would have done the same as the marketing licence number.

    I do agree though, that any time a user needs to input something, it does introduce the possibility of errors. Again, thank you for your input.

    CementCarver

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

Similar Threads

  1. Replies: 5
    Last Post: 09-25-2013, 09:35 AM
  2. Input Forms - How To Input Multiple Fields/Records?
    By butterbescotch in forum Forms
    Replies: 1
    Last Post: 04-04-2013, 06:30 AM
  3. Replies: 2
    Last Post: 11-20-2012, 03:21 AM
  4. Replies: 4
    Last Post: 10-26-2012, 12:49 AM
  5. Bound form with bound combobox
    By Jerry8989 in forum Access
    Replies: 2
    Last Post: 12-05-2011, 01:50 PM

Tags for this Thread

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