Page 3 of 3 FirstFirst 123
Results 31 to 34 of 34
  1. #31
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    I would really like to see client name and client ID come across..... if you might be so generous to show me the added code that I can use to have both come across I would be extremely grateful for your time!
    I only use the ClientID in the openArgs. You don't need to "Send" the client name across. You obtain it in the time form as you'll see below.

    heres the code with comments
    In the new client form:
    Private Sub btoSubmit_Click()
        Me.Dirty = False 'This explicitly saves the new client record
        DoCmd.OpenForm "frmTime", , , , acFormAdd, , Me.ClientID  ' this line opens the time form in data add mode and sets the OpenArgs to the new ClientID.
        DoCmd.Close acForm, Me.Name  ' this line closes the new client form
    End Sub
    in form frmTime: (note the 2nd line which is not in the example. I present it here just as an option instead of the first line. The first line will dirty the record while the 2nd line wont)

    Private Sub Form_Load()
        Me.ClientID = Me.OpenArgs  'this line sets the ClientID to the value of OpenArgs. Note that it will instantiate a new record
        'Me.ClientID.DefaultValue = Me.OpenArgs  'You can use this line instead of the above line and a new record wont be instantiated until you dirty the form
    End Sub
    the recordsource of frmTime is:
    SELECT tblTime.HoursID, tblTime.ClientID, tblTime.StartTime, tblTime.EndTime, tblClients.FName, tblClients.LName, [FName] & " " & [LName] AS ClientName
    FROM tblTime INNER JOIN tblClients ON tblTime.ClientID = tblClients.ClientID;
    which looks like this in the QBE
    Click image for larger version. 

Name:	sql123.png 
Views:	16 
Size:	13.3 KB 
ID:	43009

    You'll notice that the client table is joined to the time table by clientID. the last field in the QBE grid is the first and last name concatenated and aliased as ClientName. You then can use ClientName as a field on the form.

    Hope this makes sense to you.

    Good Luck

  2. #32
    kelliejean is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2020
    thank you so much for the in depth reply moke123, it really helped me and I've got it all set up and sorted! Woo hoo! thanks an absolute million for taking time out to help this absolute newbie, I really appreciate it!!!!! One more problem to get sorted and I'm almost there, yay!

  3. #33
    virgilio is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2019
    Quote Originally Posted by kelliejean View Post
    thanks so much virgilio! I might give this a try at some point - it seems practical - I'm just not sure where you would put the code? Form, click button.......gawd, being a newbie to this stuff is panful! LOL.
    If you ever use it, it would look like this,

    Private Sub Form_Open(Cancel As Integer)
       Dim StrSql As String
       ' This is your original statement commented out
       'Me.[Client name] = Me.OpenArgs
       'This does the work of that statement
       StrSql = " INSERT INTO YOUR_TABLE_NAME ( THE_FIELD_YOU_WANT_TO_UPDATE ) VALUES (' " & me.OpenArgs & " ' );"
       DoCmd.RunSQL StrSql
    End Sub
    The SQL is what Access is actually doing behind the scenes when you try to run your first version. I've had a ton of trouble trying to do it your original way, which should have worked btw, see my recent thread on Runtime 2448 errors. Something goes wrong in Access under the hood that makes it intermittently fail. The Udemy classes and tutorials I've taken go straight to SQL strings, and I now think its more reliable too.

  4. #34
    kelliejean is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2020
    thanks a million virgilio

Page 3 of 3 FirstFirst 123
Please reply to this thread with any new information or opinions.

Similar Threads

  1. passing values between forms
    By CurtisC in forum Access
    Replies: 2
    Last Post: 04-13-2020, 08:55 AM
  2. Replies: 14
    Last Post: 05-26-2015, 04:30 AM
  3. passing values between forms
    By paulw in forum Access
    Replies: 4
    Last Post: 06-15-2011, 08:52 AM
  4. PASSING Values between Forms
    By chhinckley in forum Programming
    Replies: 1
    Last Post: 08-27-2010, 10:19 AM
  5. Replies: 3
    Last Post: 06-02-2009, 09:51 AM

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 - Senior Forums