473,513 Members | 2,881 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help with Subforms

Greetings. Before I begin, I have been stuck on this problem for about a
5 days, now. I have tried and just seem to be not getting anywhere. I
know that the explanation is lengthy, but I am a relative newcomer to
Access and need to be methodical until it become more familiar. Thanks
in advance for your help.

I have a form with a subform that has a subform.

form: frmEvents
subform: sfrmTrialInfo (controlname = [subfrmTI])
subform in the subform: sfrmTrialClass (controlname = [subfrmTCI])

The table structure is:
tblEvents
tblTrials (multiple trials for every Event)
tblTrialClass (multiple classes for every Trial)

I get to the frmEvents form from a form with unbound controls to setup
the criteria for the display. That form is frmDataEntry.

In frmDataEntry, I have a Combobox to select an Event for display and
two command buttons; one to open the selected event in "browse" mode to
view the Event-Trials-Classes and another to open a blank frmEvents to
create a new Event-Trials-Classes

In frmEvents there is a command button that is enabled while in "Browse"
mode that will cause frmEvents to goto a New Record and should look like
the "New" button was pressed from frmDataEntry.

Problem: The two "NEW RECORD" situations don't look the same.
1. In the "NEW RECORD" from frmDataEntry, [subfrmTI] has ENABLED=FALSE
so it's label is shaded (that's what I want), but [subfrmTCI] has
ENABLED=FALSE but it's label is not shaded. Why? How can I fix this?
2. In the "NEW RECORD" from frmEvents, [subfrmTCI] has ENABLED=FALSE and
it's controls are not displayed (even though they are displayed in the
other "NEW RECORD' scenario)? WHY? How can I fix this?

I can send a word document with the screen shots. That would make the
explanation much shorter.
Here's some of the subroutines that are behind the forms:

[color:red] frmDataEntry:
[color:blue] Private Sub btnNewEvent_Click()
On Error GoTo Err_btnNewEvent_Click

Call svContext("", strMode, 0, "")
DoCmd.Close
DoCmd.OpenForm "frmEvents", acNormal, , , acFormAdd, , "ADD"

Exit_btnNewEvent_Click:
Exit Sub

Err_btnNewEvent_Click:
Call ShowError("frmDataEntry", "btnNewEvent_Click", Err.Number,
Err.Description)
Resume Exit_btnNewEvent_Click

End Sub

[color:red] frmEvents:
[color:blue] Private Sub Form_Load()
On Error GoTo Err_Form_Load

Dim intCount As Integer
Dim db As DAO.Database
Dim rsT As DAO.Recordset
Dim strSQL As String

blnDoUpdate = False
blnDataChanged = False

'==============< BROWSE Mode >====================
If strMode = "BROWSE" Or strMode = "UNKNOWN" Then
' Disable Updates to current form
Me.AllowAdditions = False
Me.AllowEdits = False
Me.AllowDeletions = False
Me!btnSave.Enabled = False
Me!btnUndo.Enabled = False

'Find out if there are any records in tblTrials for this Event
intCount = DCount("[trialID]", _
"tblTrials", _
"[eventID] = " & Me!eventID)

' If we have records in tblTrials to display for this Event then
Disable Updates
If intCount > 0 Then
' Disable Updates to subform
Forms(Me.Name)![subfrmTI].Form.AllowAdditions = False
Forms(Me.Name)![subfrmTI].Form.AllowEdits = False
Forms(Me.Name)![subfrmTI].Form.AllowDeletions = False
Else
' Display some sort of message that says that there are no
Trials for this Event
Me![lblNoTrialRecs].Visible = True
Me![subfrmTI].Visible = False
End If

'Find out if there are any records in tblTrialClass to display
for this Event
'by first finding all the Trial Records for this Event
'Then for each Trial Record see if there are any TrialClass
Records
'If there are ANY TrialClass Records then issue the Disable
commands
If intCount > 0 Then 'If we have tblTrials records
(intCount > 0)
intCount = 0 'Reset count field
Set db = CurrentDb
strSQL = "SELECT * FROM tblTrials " & _
"WHERE [eventID] = " & Me!eventID
Set rsT = db.OpenRecordset(strSQL)

If rsT.EOF Then
MsgBox "Serious Error attempting to OpenRecordset in " &
_
vbCrLf & _
"Module: " & "frmEvents" & vbCrLf & _
"Procedure: " & "Form_Load( )" & vbCrLf & _
"rs.EOF = 0 but intCount = " & intCount,
vbExclamation + vbOKOnly, _
"SERIOUS ERROR"
GoTo Exit_Form_Load
End If

rsT.MoveFirst
Do Until rsT.EOF
intCount = DCount("[trialclassID]", _
"tblTrialClass", _
"[trialID] = " & _
rsT![trialID])
If intCount > 0 Then Exit Do
rsT.MoveNext
Loop

If intCount > 0 Then 'We have some TrialClass
records
' Disable Updates to nested subform

Forms(Me.Name)![subfrmTI]![subfrmTCI].Form.AllowAdditions = False
Forms(Me.Name)![subfrmTI]![subfrmTCI].Form.AllowEdits =
False

Forms(Me.Name)![subfrmTI]![subfrmTCI].Form.AllowDeletions = False
Else
' Display a message that says that there are no Classes
for any Trials
End If

rsT.Close
Set rsT = Nothing
Set db = Nothing

End If ' End of Trial Records

End If ' End of BROWSE Mode

'==============< ADD Mode >====================
If strMode = "ADD" Then
' Enable Updates to current form
Me.AllowAdditions = True
Me.AllowEdits = True
Me.AllowDeletions = True

Me![btnAddEvent].Enabled = False
Me![btnEdit].Enabled = False
Me![btnDelete].Enabled = False
Me![btnUndo].Enabled = True
Me![btnSave].Enabled = True
Me!subfrmTI.Enabled = False

Me!lblNoTrialRecs.Visible = True
Forms(Me.Name)![subfrmTI].Form![lblNoClassRecs].Visible = True
Forms(Me.Name)![subfrmTI]![subfrmTCI].Form.Visible = True
'Forms(Me.Name)![subfrmTI]![subfrmTCI].Form.Enabled = False

End If

Me!lblWindowStatus.Caption = strMode & " Mode"

Exit_Form_Load:
Exit Sub

Err_Form_Load:
Call ShowError("frmEvents", "Form_Load", Err.Number,
Err.Description)
Resume Exit_Form_Load

End Sub

[color:red] frmEvents:

[color:blue] Private Sub btnAddEvent_Click()
On Error GoTo Err_btnAddEvent_Click

strMode = "ADD"

If blnDataChanged = True Then
Call DataHasChanged
End If

blnDoUpdate = False
blnDataChanged = False

Me.AllowAdditions = True
Me.AllowEdits = True
Me.AllowDeletions = True
Forms(Me.Name)![subfrmTI].Form.AllowAdditions = True
Forms(Me.Name)![subfrmTI].Form.AllowEdits = True
Forms(Me.Name)![subfrmTI].Form.AllowDeletions = True
Me![subfrmTI].Visible = True
'Me!subfrmTI.Enabled = False
Me!lblNoTrialRecs.Visible = True

DoCmd.GoToRecord , , acNewRec

Me!lblWindowStatus.Caption = strMode & " Mode"
Me!eventname.SetFocus
Me!btnAddEvent.Enabled = False
Me!btnDelete.Enabled = False
Me!btnEdit.Enabled = False
Me!btnSave.Enabled = True
Me!btnUndo.Enabled = True
Me![subfrmTI].Enabled = False

Exit_btnAddEvent_Click:
Exit Sub

Err_btnAddEvent_Click:
Call ShowError("frmEvents", "btnAddEvent_Click", Err.Number,
Err.Description)
Resume Exit_btnAddEvent_Click

End Sub
[color:red] frmTrialInfo:

[color:blue] Private Sub Form_Load()
'Find out if we have any Trail Records
If Me.RecordsetClone.EOF Then
blnYesRecords = False
Else
blnYesRecords = True
End If
End Sub


[color:red] frmTrialInfo:

[color:blue] Private Sub Form_Current()
On Error GoTo Err_Form_Current

Dim intCount As Integer
Dim db As DAO.Database
Dim rsT As DAO.Recordset
Dim strSQL As String
If blnYesRecords Then 'If there are TRIAL RECORDS then do the
following
If strMode = "BROWSE" Or strMode = "UNKNOWN" Then
'Find out if there are any records in tblTrialClass for this
Trial
intCount = DCount("[trialclassID]", _
"tblTrialClass", _
"[trialID] = " & Me!trialID)
If intCount = 0 Then
' Display message that says there are no Classes for
this Trial
Me![lblNoClassRecs].Visible = True
Me![subfrmTCI].Visible = False
Else
Me![lblNoClassRecs].Visible = False
Me![subfrmTCI].Visible = True
End If
End If ' End of BROWSE/UNKNOWN Mode

Me![cboTrialRep] = Me![repID]
End If ' End of YES TRIAL RECORDS EXIST

Exit_Form_Current:
Exit Sub

Err_Form_Current:
Call ShowError("sfrmTrialInfo", "Form_Current", Err.Number,
Err.Description)
Resume Exit_Form_Current
End Sub


Can you help me get the two "NEW RECORD" scenarios to look the same?
Regards,
SueB

Regards,
SueB

*** Sent via Developersdex http://www.developersdex.com ***
Nov 13 '05 #1
2 2117
rkc
Susan Bricker wrote:
Greetings. Before I begin, I have been stuck on this problem for about a
5 days, now. I have tried and just seem to be not getting anywhere. I
know that the explanation is lengthy, but I am a relative newcomer to
Access and need to be methodical until it become more familiar. Thanks
in advance for your help.


<snip a-lot-o-stuff>

That was way to much to wade through.
Are you willing to post the.mdb file somewhere (not here) it
can be downloaded?
Nov 13 '05 #2
rkc,

I agree ... to much stuff to wade through. Sure, I'll post the mdb
somewhere. Just let me know where. Keep in mind that this database is
"under construction". Thanks.

I'll look for your reply post.

Regards,
SueB

*** Sent via Developersdex http://www.developersdex.com ***
Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4787
by: Dalan | last post by:
I have tried both methods of using DSum and creating a Function to address summing some number columns, but to no avail. Since this has been a popular topic over the years, I'm sure I'll receive some guidance. This is related to Access 97 and involves my redoing a miscellaneous purchase and sales form. A main form (frmMain) is used that...
3
3995
by: Evil | last post by:
Hi, i have a problem with a treeview and some subforms in MS Access97. I have a form with a treeview on the left side which lets me navigate thru some projects. Then on the right side, i have several Tabs, each with a subform. Now, my tree view nodclick code goes like: sProjNum = me.tvwX.SelectedItem.Key
5
2619
by: Richard Stanton | last post by:
Hello all My database has a main form linked to table1. It has several subforms on the main form, all linked to table2. Table1 and Table2 are linked by primary/foreign key, no duplicates allowed, one-to-one. If I update field(s) on a single subform it works fine but when I update fields on multiple subforms ie without closing the form...
8
3066
by: Zlatko Matiæ | last post by:
Hello. How can I synchronize subforms content with current record in master form, if both form and subform are based on DAO code ? I assigned DAO recordset to forms by using QueryDef, on Load event. Thanks...
8
11498
by: ken | last post by:
Hi, I have a form that depending on certain criteria locks all of the subforms on this form. The problem is when the code unlocks the subforms their "allowedits" "allowdeletions" and "allowadditions" properties are set to "NO". I believe when the main form locks the subforms it sets these "allow" properties to "no". But when the subforms are...
2
5171
by: emc_cos | last post by:
I have a very nice parent child relationship happening between a main form and 8 subforms. The main form is the data entry point for a table that holds textual data like names, notes and the like. It also holds the primary key which is an alpha-numeric file designation. The subforms are the data entry point for another table that holds...
0
1365
by: sparks | last post by:
I was using this to swap out a form with subforms on it by just making a copy and tying each to copy of the same table. subformV1 tblVisit1 subformV2 tblVisit2 etc Select Case TabCtl0.Value Case 0: 'Initial Visit Child6.SourceObject = "subformV1"
3
2578
by: 6afraidbecause789 | last post by:
Think school - students - discipline interventions - misbehaviors - staff for this one....On a mainform frmStudentInterventions, I have linked a subform (sfrmMisbehaviors) with another subform (sfrmInterventions) with the Child and Master fields "InterventionID." This is tested and works - as users click through the continuous list of...
1
1842
by: c0l0nelFlagg | last post by:
I need to display a main form with 48 identical subforms. 6 columns with 8 rows. I set up a separate query for each subform, identical in structure and underlying data except the criteria in two fields is different for each. (ie Row and Column id fields). I am able to select data in each subform from combo box lists, then on after...
5
2266
sickenhoofer
by: sickenhoofer | last post by:
I have a form w several subforms. The ultimate goal would be to click on a location, and have the data in the other subforms change to the data specific to that location. For this form, there are 4 main tables (below). Here is the pertinent detail for the tables involved. tblProviderMain (table 1) ProviderMainID (PK, Autonum) ...
0
7177
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7123
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7542
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5701
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5100
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4756
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3237
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
811
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
470
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.