+ Reply to Thread
Results 1 to 15 of 15

Need Help Please In capturing the value in text in Access 2010

  1. #1
    Registered User
    Join Date
    01-30-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    16

    Need Help Please In capturing the value in text in Access 2010

    I have created a form and need access to capture the value ( which is email address ) in text34 which is a text box and have written the below code however when access tries to send the email in the To section Text34.text appears instead of the value in the text 34. Please advise how can access capture the value (email address ) which is in textbox 34 in the form.

    DoCmd.SendObject acForm, "Leave Approval Form", "PDFFormat(*.pdf)", "Text34.text", "", "", "RE : Leave Request Status", "Please review the status in the attachment.", True, ""

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,888

    Re: Need Help Please In capturing the value in text in Access 2010

    I would make the text box a variable by defining it in your code as a string.

    Please Login or Register  to view this content.
    Then change the "text34.text" to emailTo without any quotation marks.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    01-30-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Need Help Please In capturing the value in text in Access 2010

    Alan,

    You are brilliant. Thank you very much. It works like a flower.

  4. #4
    Registered User
    Join Date
    01-30-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Need Help Please In capturing the value in text in Access 2010

    Another question. I need the form ( acForm ) to be empty for the next user after the email is sent with the below code. Currently the user has to navigate using the next button to go to a blank form to update the details. Please advise how do i do it.

    DoCmd.SendObject acForm, "Leave Approval Form", "PDFFormat(*.pdf)", "Text34.text", "", "", "RE : Leave Request Status", "Please review the status in the attachment.", True, ""

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,888

    Re: Need Help Please In capturing the value in text in Access 2010

    before the End Sub line in your code put this line of code

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    01-30-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Need Help Please In capturing the value in text in Access 2010

    Thank you. It works. I have created a module for datediffexclude to exclude saturdays & sundays while calculating the total days between two days however i get an error station undefined function when i try to call it in a query & if i try to use it under calculated field in a table i get a message stating it cannot be used in calculated fields. Please advise.

  7. #7
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,888

    Re: Need Help Please In capturing the value in text in Access 2010

    First, although MS allows for calculations in tables in 2010, it is a bad practice to adopt. It goes against the principles of RDBMS. If you would want to move your db to another system, ie. MySQL or something else, you would have to revamp your tables and anything that relates to the data as it would not work.

    Now as to the issue with calling the function into your query. Suggest you post your code for the function. Then post the SQL statement for the query where you are trying to employ the function.

  8. #8
    Registered User
    Join Date
    01-30-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Need Help Please In capturing the value in text in Access 2010

    Function DateDiffExclude(pstartdte As Date, _
    penddte As Date, _
    pexclude As String) As Integer

    Dim WeekHold As String
    Dim WeekKeep As String
    Dim FullWeek As Integer
    Dim OddDays As Integer
    Dim n As Integer

    WeekHold = "1234567123456"
    FullWeek = Int((penddte - pstartdte + 1) / 7) * (7 - Len(pexclude))
    OddDays = (penddte - pstartdte + 1) Mod 7
    WeekKeep = Mid(WeekHold, Weekday(pstartdte), OddDays)
    For n = 1 To Len(pexclude)
    OddDays = OddDays + (InStr(WeekKeep, Mid(pexclude, n, 1)) > 0)
    Next n

    DateDiffExclude = FullWeek + OddDays


    End Function

  9. #9
    Registered User
    Join Date
    01-30-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Need Help Please In capturing the value in text in Access 2010

    SELECT [Main Table].Employee_Name, [Main Table].Leave_Apply_Date, [Main Table].Leave_Start_Date, [Main Table].Leave_End_Date, [Main Table].Total_Daysof_Leave, [Main Table].Comments, [Main Table].Approval_Status, [Main Table].Manager_Comments, [Main Table].[Email Address]
    FROM [Main Table]
    WHERE ((([Main Table].Employee_Name) Is Not Null) AND (([Main Table].Leave_Apply_Date) Is Not Null) AND (([Main Table].Leave_Start_Date) Is Not Null) AND (([Main Table].Leave_End_Date) Is Not Null) AND (([Main Table].Total_Daysof_Leave) Is Not Null) AND (([Main Table].Comments) Is Not Null) AND (([Main Table].Approval_Status) Is Not Null) AND (([Main Table].Manager_Comments) Is Null) AND (([Main Table].[Email Address]) Is Not Null));


    I want to call the function/module datediffexclude for which the code is given above under Total_DaysOf_Leave. Please advise.

  10. #10
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,888

    Re: Need Help Please In capturing the value in text in Access 2010

    I want to call the function/module datediffexclude for which the code is given above under Total_DaysOf_Leave.
    I don't understand this statement. Usually when you call a formula from a UDF, it would be in an expression in the field name location on the grid.
    ie. Total Days Leave: Your expression.

    Your total days of leave appears to already be a field in you Main Table. You will need to clarify.

  11. #11
    Registered User
    Join Date
    01-30-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Need Help Please In capturing the value in text in Access 2010

    Please see attached screenshot where i have used an expresion for Total days of leave in the main table which will give me the number of days between leave start date & leave end date. However i need the total days of leave to exclude saturdays & sundays while doing the calculation. When i try to call the function DateDiffExclude in the query under total days of leave i get an error stating undefined function per attached screenshot. Please advise.
    Attached Images Attached Images

  12. #12
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,888

    Re: Need Help Please In capturing the value in text in Access 2010

    Sorry, I don't work with calculated fields in tables. As I indicated before this is a bad practice. I can't help you as it is not something I am familiar with.

    EDIT: FYI http://allenbrowne.com/casu-14.html

  13. #13
    Registered User
    Join Date
    01-30-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Need Help Please In capturing the value in text in Access 2010

    I have removed the calculated field in the table. Could you please tell me what expression i should use to call UDF to calculate the number of days between dates excluding weekends.

  14. #14
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,888

    Re: Need Help Please In capturing the value in text in Access 2010

    You would call your UDF in the same manner you would call any other function in a query. Create a new field in your query. Give it a name and write your expression using the UDF. ie. NewFieldName: YourUDF([FieldNameToBeActedUpon])

    No differnt from: SumofSomething: Sum([SomethingField]+[SomeOtherField])

  15. #15
    Registered User
    Join Date
    01-30-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Need Help Please In capturing the value in text in Access 2010

    Thank you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1