sub form as form view not datasheet (1 Viewer)

lizcliff

Registered User.
Local time
Today, 05:34
Joined
Feb 23, 2013
Messages
38
Hi

I could not get my subform as form view, even though default shows as form / single form etc - there is no option on subform properties.

so I did an event proc on opening the form:
DoCmd.RunCommand acCmdSubformFormView

which worked!

however now my master and child links seems now don't work. they still show in the data section.

if I open form manually sub form appears as datasheet and ID fields populate..

thanks Liz
 

Micron

AWF VIP
Local time
Today, 08:34
Joined
Oct 20, 2018
Messages
3,476
If by "subform" you mean the form and not the subform control, then it is possible. Subform view set to single form BUT allow datasheet view must be "no". I don't think that should have any effect on your link properties, so if that doesn't help, you might have altered them such that now they're out of whack.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 05:34
Joined
Oct 29, 2018
Messages
21,358
Hi Liz. If you could post a sample copy of your db, we might be able to look.
 

lizcliff

Registered User.
Local time
Today, 05:34
Joined
Feb 23, 2013
Messages
38
thank you - how would I post a sample?
I do have confidential details within it, unless I could post pics of each form or would that not help
 

lizcliff

Registered User.
Local time
Today, 05:34
Joined
Feb 23, 2013
Messages
38
Hi

its working! as soon as I enter some data input into the subform it the brings through the ID giving the link


however; its a new referral ID that is being generated in subform instead of the one already there in referrals form. I took data entry off that form but then it auto populates a patient ID where I want them to search for one and then add data into the subform.

fix one thing break another seems to be my case here

thanks
 

Dreamweaver

Well-known member
Local time
Today, 12:34
Joined
Nov 28, 2005
Messages
2,466
Have you run the compact and repair as sometimes I get funny things happening esp when developing the system


hope it helps


mick
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 20:34
Joined
May 7, 2009
Messages
19,175
so your subform now is detached (standalone) from the mainform?!
what is the original Masterl/child link fields, before you detached it?

you may try to add code to the BeforeInsert event of your ex-subform:
Code:
Private Sub Form_BeforeInsert(Cancel As Integer)
    'check if the main form is open
    If SysCmd(acSysCmdGetObjectState, acForm, "theMainFormNameHere") <> 0 Then
       'populat the field (same as liked subform)
        Me.[theChildLinkField1] = [Forms]![theMainFormName]!ParentLinkField1 
        'if there are more link fields add it below
        'Me![theChildLinkField2] =  Forms![theMainFormName]![ParentLinkField2]
    Else
        MsgBox "<theMainFormName> is not open. Cannot add record."
        Cancel = True
    End If
End Sub
 

lizcliff

Registered User.
Local time
Today, 05:34
Joined
Feb 23, 2013
Messages
38
Hi

I hope I have done this right; signed up to dropbox to hopefully share a pic..

https://www.dropbox.com/s/zmswjjzvuet92w5/subform1.png?dl=0

its just adding a new referral each time when populating sub form instead of using referral selected :banghead:
 

lizcliff

Registered User.
Local time
Today, 05:34
Joined
Feb 23, 2013
Messages
38
so your subform now is detached (standalone) from the mainform?!
what is the original Masterl/child link fields, before you detached it?

you may try to add code to the BeforeInsert event of your ex-subform:
Code:
Private Sub Form_BeforeInsert(Cancel As Integer)
    'check if the main form is open
    If SysCmd(acSysCmdGetObjectState, acForm, "theMainFormNameHere") <> 0 Then
       'populat the field (same as liked subform)
        Me.[theChildLinkField1] = [Forms]![theMainFormName]!ParentLinkField1 
        'if there are more link fields add it below
        'Me![theChildLinkField2] =  Forms![theMainFormName]![ParentLinkField2]
    Else
        MsgBox "<theMainFormName> is not open. Cannot add record."
        Cancel = True
    End If
End Sub


they are still linked: in the sub-form properties its all still then same
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 20:34
Joined
May 7, 2009
Messages
19,175
the link is void (non-functional) if you detached it.
 

lizcliff

Registered User.
Local time
Today, 05:34
Joined
Feb 23, 2013
Messages
38
I might re do the sub form see if that works; with the code of opening form in it to start with.
is there a way to search for a patient number and referral date to ensure I get the correct referral, as a patient could have two referrals so I need to know which one to enter the therapy data to.
 

lizcliff

Registered User.
Local time
Today, 05:34
Joined
Feb 23, 2013
Messages
38
so your subform now is detached (standalone) from the mainform?!
what is the original Masterl/child link fields, before you detached it?

you may try to add code to the BeforeInsert event of your ex-subform:
Code:
Private Sub Form_BeforeInsert(Cancel As Integer)
    'check if the main form is open
    If SysCmd(acSysCmdGetObjectState, acForm, "theMainFormNameHere") <> 0 Then
       'populat the field (same as liked subform)
        Me.[theChildLinkField1] = [Forms]![theMainFormName]!ParentLinkField1 
        'if there are more link fields add it below
        'Me![theChildLinkField2] =  Forms![theMainFormName]![ParentLinkField2]
    Else
        MsgBox "<theMainFormName> is not open. Cannot add record."
        Cancel = True
    End If
End Sub


hi
ii tried this and I just get the main form is not open message?#
 

lizcliff

Registered User.
Local time
Today, 05:34
Joined
Feb 23, 2013
Messages
38
I think I know why
because I have it as data entry, it is creating a new ID like it would in the original table as its autonunmber.

if I put it to no data entry I cannot have it as a search / combo box?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 05:34
Joined
Oct 29, 2018
Messages
21,358
I've took all patient detail out replaced with dummy - just a handful and added two referrals ive tried to add therapies too.
https://www.dropbox.com/s/s12er4u11nau4f8/stroke liz test.accdb?dl=0
(not sure you can share DB on here)

i just cant get the Ids to link f - eel like starting again
I'm wondering its something anyone can easily spot ?
but I'm outta ideas.
thanks
Hi liz. I downloaded your file (FYI, it's 286MB); but unfortunately, I got the following error when I tried to open it.





When I clicked OK, I was able to open your database, but all code are gone. When I opened the form Therapy_Assessments subform in Design View, the Default View property was set to Datasheet (even though the Allow Datasheet View was set to No - I didn't think this should be possible, so your file or form may be corrupt, which could be why I got the initial error when opening your file). When I changed it to Single Form and saved the changes, I was able to open the form Referrals_t1 with the subform showing as a form rather than as a datasheet (Remember, all the code are gone, and I didn't even clicked the Enable Content button or stored your file in a Trusted Location). Hope it helps...
 

Attachments

  • error.png
    error.png
    11 KB · Views: 358

lizcliff

Registered User.
Local time
Today, 05:34
Joined
Feb 23, 2013
Messages
38
thanks does this mean i have to start again...
 

lizcliff

Registered User.
Local time
Today, 05:34
Joined
Feb 23, 2013
Messages
38
Thanks you
I have taken all code out and re-saved and able to change from datatsheet to single form - YAY

but the ID still shows differently, it should bring in the ID from referrals table when select hosp number so it makes that link.?

but the sub forms works without any code :)
 

theDBguy

I’m here to help
Staff member
Local time
Today, 05:34
Joined
Oct 29, 2018
Messages
21,358
Thanks you
I have taken all code out and re-saved and able to change from datatsheet to single form - YAY

but the ID still shows differently, it should bring in the ID from referrals table when select hosp number so it makes that link.?

but the sub forms works without any code :)
Hi. My guess is your file may be corrupt. You might try creating a new form or export all your objects into a fresh file.
 

lizcliff

Registered User.
Local time
Today, 05:34
Joined
Feb 23, 2013
Messages
38
thanks i m ight jut have to

i think it could have something to do with the referralT1 form when searching for a hospital number, control source is hospital number but i need to be able to search number and ref date to reconcile them to a referral but the data entry clerk only knows the hosp number so i need them together in the search-
but then is appends into referrals table as [hosp number and date] in hosp number column - creating a new ID - any ideas on that thought?
I'm determined to solve it
thanks for your help
 

theDBguy

I’m here to help
Staff member
Local time
Today, 05:34
Joined
Oct 29, 2018
Messages
21,358
thanks i m ight jut have to

i think it could have something to do with the referralT1 form when searching for a hospital number, control source is hospital number but i need to be able to search number and ref date to reconcile them to a referral but the data entry clerk only knows the hosp number so i need them together in the search-
but then is appends into referrals table as [hosp number and date] in hosp number column - creating a new ID - any ideas on that thought?
I'm determined to solve it
thanks for your help
Hi. Create a fresh copy and try to post it again, so we can take another look.
 

Users who are viewing this thread

Top Bottom