Results 1 to 9 of 9
  1. #1
    HillChris7714 is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2016
    Posts
    14

    How can I set the textbox on a subform in Datasheet mode?

    So, I have a (Split) Form that contains a SubForm. On that SubForm, I have a text box that is assigned by a VBA module, like so:



    Code:
    Private Sub Form_Current()
        Dim frm As Form
        Set frm = Forms![Form1]![Table2 subform].Form
        frm.txtCalculated = "SUCCESS!"
    End Sub
    The Field is calculated on the bottom portion of the split form, but not in the top portion:

    Click image for larger version. 

Name:	CaptureNew.JPG 
Views:	20 
Size:	49.0 KB 
ID:	25492

    My 2 Questions are...

    1. Why? What do I have to do to set the text box on the top portion as well? Is that even possible?

    2. How come, when I go into Datasheet view (by clicking View > Datasheet), I get the following error on the following line of code:

    Click image for larger version. 

Name:	ErrLayout.jpg 
Views:	20 
Size:	50.7 KB 
ID:	25493

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,526
    You dont create a new form in vb, it's already there physically.
    so assign the subForm object to the existing. But you don't even need vb. just assign it in form design.
    use full paths.

  3. #3
    HillChris7714 is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2016
    Posts
    14
    Quote Originally Posted by ranman256 View Post
    You dont create a new form in vb, it's already there physically.
    so assign the subForm object to the existing. But you don't even need vb. just assign it in form design.
    use full paths.
    Well see, for a variety of reasons which are all very boring, the field has to be assigned in VBA... let's just say there's an über-complicated calculation that assigns the value of that field. Essentially, I'm just trying to figure out how to make sure the form that appears in the top portion behaves the same way it does in the bottom half.

    As far as the error is concerned, for now I'm just disabling Datasheet view. Which is kind of hammy to me... they're trying to use Datasheet View, they're getting an error, I can't fix it, so I just disable Datasheet View. I mean, that doesn't fix anything really. They still can't use Datasheet View - but, now it's by design.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    1. Why? What do I have to do to set the text box on the top portion as well? Is that even possible?
    What is this top portion you are referring to? If you have a control in the main form that you want to assign a value to, use something like the following in the main form's module.
    Me.ControlName.Value = "Some Value"
    2. How come, when I go into Datasheet view (by clicking View > Datasheet), I get the following error on the following line of code:
    Apparently, that feature/option is not available while in DS view.

  5. #5
    HillChris7714 is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2016
    Posts
    14
    Quote Originally Posted by ItsMe View Post
    What is this top portion you are referring to? If you have a control in the main form that you want to assign a value to, use something like the following in the main form's module.
    Me.ControlName.Value = "Some Value"
    Apparently, that feature/option is not available while in DS view.
    Can you not see the screenshots attached to the OP? The big red question mark with the arrow points to exactly what I'm talking about. Not to be a smart aleck, but I don't know how to make it more clear...

    And, as far as the feature/option not being available... you can see the subform on datasheet view just like you can on the top portion of the split form. It's there. So, it must be available. All you have to do is open a Form that has a subform and switch to Datasheet view. You see the plus sign on the left? That expands to show the subform. The subform is there. Why can't I reference it? That's the gist of the issue.

  6. #6
    HillChris7714 is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2016
    Posts
    14
    Maybe this will help. Here's a link to a test Database where you can actually see what I'm talking about: http://expirebox.com/download/bbf0dc...edc14cec5.html

    Load Form1. Notice the Calculated Field is set to "SUCCESS!!!" Yet, if you expand the record above, you'll see the same field is not populated.

    Also, click View > Datasheet. You will then see the error in question.

  7. #7
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by HillChris7714 View Post
    Can you not see the screenshots attached to the OP?...
    Yeah, your pictures are posting OK. I understood that control as the one you referenced in your VBA code, where you assigned a value. If there is another control you need to assign a value to, you just need to get the correct namespace. That is why I included the example using the Me shortcut (Me.ControlName.Value = "Hello world")

    I did not have time to test the Datasheet thing. IIRC, you will not be able to reference a container in a form while in DS view.

  8. #8
    HillChris7714 is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2016
    Posts
    14
    Well, that sucks. I mean, I appreciate you telling me straight up that it can't be done. I've gone through a bit of a headache trying to find an answer to this question. And, to this point, what I've gotten is a bunch of attitude from people about how I'm asking the question, and "why would you want to do that?" and... basically trying to make it MY fault that I'm asking the question. When, as I suspected, it's probably because they just don't want to admit that Access isn't sufficient to accomplish what I want, so somehow it's my fault.

    I mean, I'm not the architect of this solution. I'm not the Project Manager... basically I'm a .Net MVC developer who was handed this to basically patch up until we can do a full re-write. So, "It can't be done" is totally acceptable in my eyes. I can just go back to my PM, tell them it can't be done, and people will just have to deal until we can rewrite the app in a more comprehensive development framework. Personally, I would never recommend Access to do pretty much anything. If it's too big for Excel, it needs to be in SQL with a .Net or PHP front-end. I didn't recommend the app be written in Access, so I'm not accepting responsibility for its limitations.

    They would probably actually be upset if they found out how much time I burned trying to fix this (seemingly) simple problem.

  9. #9
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,742
    I'm not sure I follow what you are trying to do.
    I did download your database, and established referential integrity through relationships (1 to many between table1 and table2 id-->TID)

    I added a textbox Text5 on form1 and modified code as below
    Code:
    Private Sub Form_Current()
        Dim frm As Form
        Set frm = Forms![form1]![Table2 subform].Form
        frm.txtcalculated = "SUCCESS!!!"
        Forms!form1.Text5 = frm.txtcalculated
    End Sub
    and form displays

    Click image for larger version. 

Name:	formSuccess.jpg 
Views:	11 
Size:	17.8 KB 
ID:	25510

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

Similar Threads

  1. Replies: 3
    Last Post: 01-07-2016, 10:29 AM
  2. Replies: 16
    Last Post: 01-16-2012, 09:43 AM
  3. Replies: 2
    Last Post: 09-01-2011, 10:48 PM
  4. Replies: 4
    Last Post: 01-14-2011, 10:37 AM
  5. Replies: 6
    Last Post: 09-02-2010, 02:18 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