Results 1 to 8 of 8

Thread: Two queries

  1. #1
    Join Date
    May 2011
    Posts
    7

    Lightbulb Two queries

    Hi,

    I am on a access form. Is there any ways by which if i press the button, the data gets added to the table and the data entered in the form gets on to outlook (via sendobject)....in one go...

    i mean how to make these things in one single query?

    Regards,

    T

  2. #2
    Join Date
    Mar 2006
    Location
    Oklahoma City, OK
    Posts
    184
    Quote Originally Posted by Tajinderp View Post
    Hi,

    I am on a access form. Is there any ways by which if i press the button, the data gets added to the table and the data entered in the form gets on to outlook (via sendobject)....in one go...

    i mean how to make these things in one single query?

    Regards,

    T
    T,

    In the On click event of a command button try something like this:


    Code:
    ' Save the record if needed
    If Me.Dirty Then Me.Dirty = False
    
    ' Send
    Docmd.SendObject ...

    You will need to enter the desired parameter for the SendObject
    Boyd Trimmell aka HiTech Coach
    Microsoft MVP - Access Expert
    [SIGPIC][/SIGPIC]
    Office Programming 25+ years as a Software Developer specializing in:
    Business Process Management
    Accounting/Inventory Control
    Customer Relations Management (CRM)
    Electronic Data Interchange (EDI)

  3. #3
    Join Date
    May 2011
    Posts
    7

    thanks for replying

    so if i have a table attached to the form...which says table 1...how will i be able to save the data in that one?

    right now my code says...

    Private Sub Save_Record_Click()
    On Error GoTo Err_Save_Record_Click


    DoCmd.GoToRecord , , acNewRec

    Exit_Save_Record_Click:
    Exit Sub

    Err_Save_Record_Click:
    MsgBox Err.Description
    Resume Exit_Save_Record_Click

    End Sub

    Due to this code, i get to save data and move to the next record...or u can say addrecord....

    how to make things work with this one...

  4. #4
    Join Date
    Mar 2006
    Location
    Oklahoma City, OK
    Posts
    184
    By default, Access saves a record as soon as you navigate away.

    If all you wan to do is save the record then use the code I posted previously like this:

    Code:
    Private Sub Save_Record_Click()
    On Error GoTo Err_Save_Record_Click
    
    ' Save the record if needed
    If Me.Dirty Then Me.Dirty = False
    
    Exit_Save_Record_Click:
    Exit Sub
    
    Err_Save_Record_Click:
    MsgBox Err.Description
    Resume Exit_Save_Record_Click
    
    End Sub
    Boyd Trimmell aka HiTech Coach
    Microsoft MVP - Access Expert
    [SIGPIC][/SIGPIC]
    Office Programming 25+ years as a Software Developer specializing in:
    Business Process Management
    Accounting/Inventory Control
    Customer Relations Management (CRM)
    Electronic Data Interchange (EDI)

  5. #5
    Join Date
    May 2011
    Posts
    7
    thanks sir...and where do i adjust the sendobject in this code?

  6. #6
    Join Date
    Mar 2006
    Location
    Oklahoma City, OK
    Posts
    184
    If you only want it to send when a record has been saved/updated then I would use the Form's After Update Event to run the Docmd.SendObject. This way it only sends after a successful save.
    Boyd Trimmell aka HiTech Coach
    Microsoft MVP - Access Expert
    [SIGPIC][/SIGPIC]
    Office Programming 25+ years as a Software Developer specializing in:
    Business Process Management
    Accounting/Inventory Control
    Customer Relations Management (CRM)
    Electronic Data Interchange (EDI)

  7. #7
    Join Date
    May 2011
    Posts
    7
    i did that....thanks sir...

  8. #8
    Join Date
    Mar 2006
    Location
    Oklahoma City, OK
    Posts
    184
    You're welcome.
    Boyd Trimmell aka HiTech Coach
    Microsoft MVP - Access Expert
    [SIGPIC][/SIGPIC]
    Office Programming 25+ years as a Software Developer specializing in:
    Business Process Management
    Accounting/Inventory Control
    Customer Relations Management (CRM)
    Electronic Data Interchange (EDI)

Posting Permissions

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