Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    Join Date
    Nov 2009
    Posts
    223

    Unanswered: Making a Contract in a Text Box?

    I want to make a small Contract and automatically print certain [Fields] within the wording.

    Eg. "This is a Contract between [Owner Name] and [Renter Name]. This Contract start from [Start Date] until [End Date] at a monthly rent of [Rental Amount]. etc etc"

    There will be many Contracts between many Owners and Renters.

    What do you think would be the best way to design these Contracts? I would like all the wording to be as though the Contract has been typed out and it should not be obvious that the [Fields] have been inserted.

    I thought about making a Report but joining the [Fields] in a nice way may be a problem?
    I thought about making a large Text Box on a Form but was finding it difficult to join the words with the [Fields].

    Please could anybody suggest the best way to make this Contract?

    Thank you.
    What would you attempt to do if you knew you would not fail?

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Generally speaking, you concatenate literal text with data. If you were using the textbox control source:

    ="This is a Contract between " & [Owner Name] & " and " & [Renter Name] & "."
    Paul

  3. #3
    Join Date
    Nov 2009
    Posts
    223
    pbaldy,

    thank you for your advice.

    i fumbled around with a similar format but i received error messages when trying to add the [Field names]. i think i need to re-ceate my Form and try again.

    cheers.
    What would you attempt to do if you knew you would not fail?

  4. #4
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    No problem. If you're still getting errors when you recreate the form, post the failing syntax here and we'll fix it.
    Paul

  5. #5
    Join Date
    Nov 2009
    Posts
    223
    Greetings,

    I have put the following code into a TextBox.

    Code:
    ="This CONTRACT starts on " & [Find Contract Query]![Start Date (Original)]
    The Record Source of the Form is also "Find Contract Query".

    But when I go to Form View all I see is the message "#Name?". What have I done wrong??
    What would you attempt to do if you knew you would not fail?

  6. #6
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Try

    ="This CONTRACT starts on " & [Start Date (Original)]

    Also, make sure you don't have a textbox with the same name as the field, which can confuse Access. By the way, the spaces and symbols in your names aren't worth the bother in the long run.
    Paul

  7. #7
    Join Date
    Nov 2009
    Posts
    223
    Fan-dabi-dosi.......that certainly works - thanks a bunch, pbaldy
    What would you attempt to do if you knew you would not fail?

  8. #8
    Join Date
    Nov 2009
    Posts
    223
    Mmm, I now have tried to force a Carriage Return to create paragraphs.

    I read I could use

    vbCr
    vbCrLf
    vbLf
    vbNewLine

    but I guess the last one is the best?

    Code:
    ="This CONTRACT ID " & [Contract ID] & " starts on " & [Start Date (Original)] & " and ends on " & [End Date (Original)] & [vbNewLine] & " The monthly rental rate is USD " & [Monthly Rent]
    The above code gives me an error message #Name?

    I have tried to insert and remove the & but can't seem to get the correct combination?

    How many "&" should go in the code?

    Cheers to all.
    What would you attempt to do if you knew you would not fail?

  9. #9
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    The vb constants can only be used in code. Try

    ="This CONTRACT ID " & [Contract ID] & " starts on " & [Start Date (Original)] & " and ends on " & [End Date (Original)] & Chr(13) & Chr(10) & " The monthly rental rate is USD " & [Monthly Rent]
    Paul

  10. #10
    Join Date
    Nov 2009
    Posts
    223
    pbaldy,

    thanks a lot, the Chr(13) and Chr(10) combination within the code worked.

    although it seems a bit funny that it needs 2 "commands" to make a new line?

    cheers,

    Paul
    What would you attempt to do if you knew you would not fail?

  11. #11
    Join Date
    Jun 2011
    Location
    Inside your mind
    Posts
    297
    Code:
    ="This CONTRACT ID " & [Contract ID] & " starts on " & [Start Date (Original)] & _
     " and ends on " & [End Date (Original)] & vbCrLf & _
     "The monthly rental rate is USD " & [Monthly Rent]
    Can be used instead... Should work flawlessly, without need to use character codes.
    Looking for the perfect beer...

  12. #12
    Join Date
    Nov 2009
    Posts
    223
    kez1304,

    i appreciate your reply - thanks.

    i have tried your code but get the following error message:-

    "the expression you entered contains invalid syntax"

    i also deleted the "_" from your code and tried

    Code:
    ="This CONTRACT ID " & [Contract ID] & " starts on " & [Start Date (Original)] & " and ends on " & [End Date (Original)] & [vbCrLf] & "The monthly rental rate is USD " & [Monthly Rent]
    but got the #Name? message????
    What would you attempt to do if you knew you would not fail?

  13. #13
    Join Date
    Nov 2009
    Posts
    223
    I noted that the vbCrLf automatically get put into [] brackets.

    Then I get the message "The object doesn;t contain the Automation object".

    i am using Access 2003 - does that make any difference?
    What would you attempt to do if you knew you would not fail?

  14. #14
    Join Date
    Jun 2011
    Location
    Inside your mind
    Posts
    297
    I'd try simplifying it down...

    Me.tmpTestTextBox.Value = "This is a" & vbCrLf & "Test"

    Works fine for me on a command button. It updates the textbox, tmpTestTextBox, to look like:

    This is a
    Test
    How are you displaying the output? In a textbox or on a report?

    Also, the '_' indicates that the current code is moving to the next line... So:

    Code:
    strSQL = "SELECT something FROM something WHERE something ORDER BY something"
    Is the same as:

    Code:
    strSQL = "SELECT something " & _
             "FROM something " & _
             "WHERE something " & _
             "ORDER BY something"
    Just makes it easier to read on long statements, strings, etc.
    Last edited by kez1304; 09-05-11 at 08:05.
    Looking for the perfect beer...

  15. #15
    Join Date
    Nov 2009
    Posts
    223
    thanks again kez1304

    i copy and pasted the code into the Control Source of a Text Box.

    Code:
    Me.tmpTestTextBox.Value = "This is a" & vbCrLf & "Test"
    When I moved to Form view, I still get the #Name? error message??

    are you using Access 2003?
    What would you attempt to do if you knew you would not fail?

Posting Permissions

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