Results 1 to 7 of 7
  1. #1
    fspata is offline Advanced Beginner
    Windows 8 Access 2007
    Join Date
    Oct 2015
    Posts
    41

    Subform creation


    Can you create a subform after the main form has been created? If not, can you link 2 forms? My "Subform" just has 2 buttons, Check In and Check Out as options which open the main form. I want to also be able to enter NOW() into an existing table with check in and out fields.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Certainly. Just grab the subform/subreport container control from the Design tab and pull it onto the main form.

    What do you mean by 'open the main form'? Subforms do not open main forms.

    DefaultValue property can be used to set CheckIn field to populate with Now().

    Will need code to set value of CheckOut field.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    fspata is offline Advanced Beginner
    Windows 8 Access 2007
    Join Date
    Oct 2015
    Posts
    41
    All I meant was that my Check in/out buttons do an OpenForm command and I just want the table that have the Check In and Check Out fields to update with the timestamp that they execute that. Sorry for the confusion.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    So need to open filtered to appropriate record and set field with Now() value?

    Rough example:

    DoCmd.OpenForm "form name", , , "ID=" & Me.ID
    Me.fieldname = Now()
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    fspata is offline Advanced Beginner
    Windows 8 Access 2007
    Join Date
    Oct 2015
    Posts
    41
    After thinking about my whole process, I've decided to try to simplify the form and just use the Check in/out spalsh form, as I call it, exactly that. I want to set either button they choose to TRUE; Open my other form, called Initial, enter their info and press submit. This is the code I am using on the submit button. I am getting runtime error 2465.

    My Check In button runs a macro to OpenForm Initial Onclick, also the following code is in the Onclick event.

    Private Sub Command8_Click()
    Dim strTimein As String
    strTimein = True
    End Sub

    This is my Submit button on the Initial form.

    Private Sub Submit_Click()
    If Forms![Splash]!Command8 = "TRUE" Then
    '[Souls] = [Souls] + 1
    Me![Check In] = Now()
    Else
    If Forms![Splash]!Command9 = "TRUE" Then
    '[Souls] = [Souls] - 1
    Me![Check Out] = Now()
    End If
    End If
    RunCommand acCmdSaveRecord
    Me.Requery
    End Sub

  6. #6
    fspata is offline Advanced Beginner
    Windows 8 Access 2007
    Join Date
    Oct 2015
    Posts
    41
    Did I mention I was pretty new at this,

    Quote Originally Posted by fspata View Post
    After thinking about my whole process, I've decided to try to simplify the form and just use the Check in/out spalsh form, as I call it, exactly that. I want to set either button they choose to TRUE; Open my other form, called Initial, enter their info and press submit. This is the code I am using on the submit button. I am getting runtime error 2465.

    My Check In button runs a macro to OpenForm Initial Onclick, also the following code is in the Onclick event.

    Private Sub Command8_Click()
    Dim strTimein As String
    strTimein = True
    End Sub

    This is my Submit button on the Initial form.

    Private Sub Submit_Click()
    If Forms![Splash]!Command8 = "TRUE" Then
    '[Souls] = [Souls] + 1
    Me![Check In] = Now()
    Else
    If Forms![Splash]!Command9 = "TRUE" Then
    '[Souls] = [Souls] - 1
    Me![Check Out] = Now()
    End If
    End If
    RunCommand acCmdSaveRecord
    Me.Requery
    End Sub

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    The Command8 click event serves no purpose. Command buttons do not have a True/False state. Command buttons do not have any value.

    The strTimein variable declared in Command8 click event is not available to any other procedure. It has a life only within that event.

    If you want to provide db for analysis, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. PDF creation in VBA
    By BobRich99 in forum Access
    Replies: 2
    Last Post: 03-20-2015, 03:16 PM
  2. Replies: 6
    Last Post: 02-02-2015, 08:22 PM
  3. Replies: 10
    Last Post: 04-25-2014, 12:53 PM
  4. Replies: 8
    Last Post: 07-18-2013, 01:52 PM
  5. Subform not always allowing new record creation
    By Canadiangal in forum Forms
    Replies: 1
    Last Post: 03-28-2013, 11:00 PM

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