Results 1 to 9 of 9
  1. #1
    Join Date
    Oct 2002
    Posts
    88

    Unanswered: Values from form into code

    I'd like to set up a form for someone to enter or select an email address from a list which would then go into the to: poriton of a sendobject command in a macro.

    I thought I could just enter [forms]![formname]![controlname] and the value would be passed from the open form to the code. When I try this it doesn't work.

    How do you pass a value from a form into code such as sendobject?

    Thanks

  2. #2
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665

    Re: Values from form into code

    Originally posted by tmort
    I'd like to set up a form for someone to enter or select an email address from a list which would then go into the to: poriton of a sendobject command in a macro.

    I thought I could just enter [forms]![formname]![controlname] and the value would be passed from the open form to the code. When I try this it doesn't work.

    How do you pass a value from a form into code such as sendobject?

    Thanks

    set up a varaible and then set it to the combo box/text box from the form
    Jim

  3. #3
    Join Date
    Oct 2002
    Posts
    88
    I've added a variable to the code:

    The entire code is:

    Option Compare Database

    Function send()
    Dim address As String

    address = [Forms]![testform]![test]


    DoCmd.SendObject acSendQuery, "north kent users", acFormatXLS, "address", , , "North Kent Permitted User Results", "Most recent results", 0


    End Function

    I get a message saying the email cannot be sent.

    I've tried it with and without the quotes.

    Thanks

  4. #4
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665
    Originally posted by tmort
    I've added a variable to the code:

    The entire code is:

    Option Compare Database

    Function send()
    Dim address As String

    address = [Forms]![testform]![test]


    DoCmd.SendObject acSendQuery, "north kent users", acFormatXLS, "address", , , "North Kent Permitted User Results", "Most recent results", 0


    End Function

    I get a message saying the email cannot be sent.

    I've tried it with and without the quotes.

    Thanks
    Try

    DoCmd.SendObject acSendQuery, "north kent users", acFormatXLS, " & address & ", , , "North Kent Permitted User Results", "Most recent results", 0

    I think that will embed the variable in the command
    Jim

  5. #5
    Join Date
    Oct 2002
    Posts
    88

    &

    Jim,

    That doesn't work. Any other ideas?

  6. #6
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665
    I have neaver used that command before but i can tell taht the command dosent know what to do with the variable. did you put the reference to the form where address is now?
    is that where you started with this?
    by reference i meand forms![Form_Name]![formControle]
    Jim

  7. #7
    Join Date
    Oct 2002
    Posts
    88

    Forns and arguments

    Yes, I originally tried putting [forms]![formname]![controlname] where I am now putting the variable "address". That didn't work either

    Thanks

    Tom

  8. #8
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665
    ugg.
    it eather dosent like the string that is in the variable, thus it may need "" or something or it dosent know what to do with that variable
    wish I could be more help
    Jim

  9. #9
    Join Date
    Sep 2002
    Location
    Land of OZ
    Posts
    173
    Try This ... I think you will need to convert the content of the combo to a string .... worked in A2K on a W2K OS



    Dim address As String

    address = cstr([Forms]![testform]![test])


    DoCmd.SendObject acSendQuery, "north kent users", acFormatXLS, address, , , "North Kent Permitted User Results", "Most recent results", 0


    Originally posted by tmort
    I've added a variable to the code:

    The entire code is:

    Option Compare Database

    Function send()
    Dim address As String

    address = [Forms]![testform]![test]


    DoCmd.SendObject acSendQuery, "north kent users", acFormatXLS, "address", , , "North Kent Permitted User Results", "Most recent results", 0


    End Function

    I get a message saying the email cannot be sent.

    I've tried it with and without the quotes.

    Thanks
    Mona
    ________________________________
    Life is too short to be sane or sensible. Weird people rule and normal people suck

Posting Permissions

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