prevent a subform from being updated before the combo box is selected on main form

Jaymin

Registered User.
Local time
Tomorrow, 04:56
Joined
Oct 24, 2011
Messages
70
This may have been already posted but I cannot find it, I have a form that has a combo box that I select a town, then this filters the second form by the selected town, this second form has a combo box that is blank when the main form opens but the subform is populated, what i want to do is stop the subform from being populated till data from the combo box has been selected.
Peter :o
 
How are you performing the filtering of the subform via the combo box? If you're affecting the subform's filter property then you can check against its FilterOn and Filter properties and act accordingly.

If not, check against the combo box's ListIndex property or Value property and act accordingly.
 
As I am new at this, I do not understand fully what you are asking.
but the first form selects the town that I want, then when the second form opens it filters the names of the people that live in that town that was filtered from the first form, when the second form opens i have a blank combo box, if i operate the arrow of the combo box there is a list of names pertaining only to the selected town, that part is ok but when the second form opens details of the first name is visable in the subform see attached "no data combo.jpg", what i want to happen is that these details are not shown till i select a name from the main form combo box, If i select any other name in the list it filters these values ok, if i select the first name these details show ok see attached "data combo.jpg" , it is only when the second form initally opens there is data in the subform which i would like to stop happening till i select a name from the combo box.
I do not understand how to alter listindex or value property to achieve this? or the subforms filter property
Peter :(
 

Attachments

  • no data combo.jpg
    no data combo.jpg
    29.8 KB · Views: 97
  • data combo.jpg
    data combo.jpg
    26.1 KB · Views: 109
As I am new at this, I do not understand fully what you are asking.
I'm asking you to show me the code you use to filter the subform.

I do not understand how to alter listindex or value property to achieve this? or the subforms filter property
This will be explained at a later stage.
 
Vbainet,
Thank you for your time and help.
first form
Option Compare Database
Private Sub Command0_Click()
On Error GoTo Err_Command0_Click

DoCmd.Close
Exit_Command0_Click:
Exit Sub
Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click

End Sub
Private Sub Command3_Click()
On Error GoTo Err_Command3_Click
Dim stDocName As String
Dim stLinkCriteria As String
If Not IsNull(Me.Combo1) Then
stDocName = "2-tblStation"

stLinkCriteria = "[StationName]=" & "'" & Me![Combo1].Column(1) & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox "You must select a station..!"

End If
Exit_Command3_Click:
Exit Sub
Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click

End Sub

second form
Option Compare Database
Private Sub StationName_AfterUpdate()
Me.Combo10.Requiry
End Sub

second form subform
Option Compare Database
Private Sub Combo10_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[fullname] = '" & Me![Combo10] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

Option Compare Database
Sub Form_Current()
Dim ParentDocName As String
On Error Resume Next
ParentDocName = Me.Parent.name
If Err <> 0 Then
GoTo Form_Current_Exit
Else
On Error GoTo Form_Current_Err
Me.Parent![2-qryMaint Subform].Requery
End If
Form_Current_Exit:
Exit Sub
Form_Current_Err:
MsgBox Error$
Resume Form_Current_Exit
End Sub

copy of the query for the combo box is attached, hope I have submitted all that you need.
Peter :confused:
 

Attachments

  • query.jpg
    query.jpg
    30.2 KB · Views: 94
vbainet,
Thank you for the trouble you are going through to help me maybe it might be easier if i down load the data base for you to see all.
the first form is called startup select a town from the combo box and away you go.

Peter :o
 

Attachments

vbainet,
if you open the attached data base, go to forms, and select the form called "2-StartUp" that is the first form, in the combo box select a town (Gold Coast) and press the "open form combo" button, this inturn will open the second form "2-tblStation" and subforms, this is where i am having the trouble.
Peter
 
What is the name of the form I should be looking at? I don't need the steps.
 
form "2-tblStation" is where the combo box and the subform are, but you need to run the form "2-StartUp" so the combo box in the "2-tblStation" is filtered correctly

Peter
 
Problem found and fixed.
use a query with a nul critera in the record source in the subform this will stop the field from displaying " #name?" in the empty field then try not setting the RecordSource of the SubForm until the AfterUpdate event of the second form ComboBox?
 
I left this window open on my other laptop and forgot you found a fix. Anyway, I worked on a solution (that doesn't use the VBA editor) refreshed the page to post the solution and realised this was closed.

Oh, well I will post it anyway. It's different from yours.

Happy developing!
 

Attachments

Users who are viewing this thread

Back
Top Bottom