Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help needed displaying info on my switchboard form

Status
Not open for further replies.

NeilT123

Technical User
Jan 6, 2005
302
GB
I have a customer based database and have a switchboard form frmSboard. The form is unbound.

On frmSboard is a multi select combobox which is used to select the relevant customer(s) and once the selection is made I have an “Accept selection” command button which runs the following code.

Code:
Private Sub BtnAccept_Click()
Dim Q As QueryDef, DB As Database
   Dim Criteria As String
   Dim ctl As Control
   Dim Itm As Variant

    ' Select the Farm(s).
    Set ctl = Me![cboFmAccntNo]

    For Each Itm In ctl.ItemsSelected
       If Len(Criteria) = 0 Then
          Criteria = ctl.ItemData(Itm)
       Else
          Criteria = Criteria & "," & ctl.ItemData(Itm)
       End If
    Next Itm
    If Len(Criteria) = 0 Then
    Exit Sub
    End If
         
   ' Modify the Query.
   Set DB = CurrentDb()
   Set Q = DB.QueryDefs("QrySLTFarm")
   Q.SQL = "Select DISTINCT * From tblFarmerDetails Where [FarmAccountNumber] In(" & Criteria & _
     ");"
     Q.Close
DoCmd.OpenQuery "QrySLTFarm" ' Run the query
Dim Count As Integer ' this code counts the number of records and saves the value as "count" which is then used to determine the height of the Account Name text box
Count = DCount("*", "QrySLTFarm")
Me.[TbAccountName].Height = 315 * Count
Forms![frmsboard].Refresh 'refresh the Main form
Me.[TbAccountName].Visible = True
BtnChangeFarm.SetFocus
Me.[cboFmAccntNo].Visible = False
Me.[BtnAccept].Visible = False
[Forms]![frmsboard].[Form]![frmSfSBOARD].Requery
End Sub

I would like to record information against some of the customers records and for that information to show on my switchboard form frmSboard AND TO BE EDITABLE.

The way I thought about doing this was to have a subform based on the customers table and then filter it using the master/child properties but as the master form is unbound that does not work.

I then thought about having a subform frmSfSboard based on the FarmAccountNumber that the query QrySLTFarm in the above code creates and use that as the master and then a further subform as the child but I can’t get the subform to update when I change the customer and the last line of the code above is my last feeble attempt.

Questions:
Is there an easier way to do this?
If so, guidance please
If this is the best way can anyone help with the code I use to update the subform after changing the customer.

This is driving me nuts so any help would be very much appreciated.
 
Sorry there was a hang over from yesterday in the above code. The
Code:
DoCmd.OpenQuery "QrySLTFarm" ' Run the query
is not needed
 
NeilT123 said:
The way I thought about doing this was to have a subform based on the customers table and then filter it using the master/child properties but as the master form is unbound that does not work.
Why doesn't it work? I use link master/child quite often when the main form is not bound. You only need to reference a control with a value on the main form as the Link Master.

Duane
Hook'D on Access
MS Access MVP
 
Sorry Duane my brain is totalled screwed on this. I am not really sure what you mean.

FYI I am using Access 2003.
 
The main form has no record source and so when I click on the 3 dots next to the Link Child or Link Master boxes in the subform I get an error message saying can't build a link between unbound forms and I don't know any other way of linking forms.

 
In case it helps someone I sorted this by changing the code to create a temporary table rather than a query and then linked the subform to the table.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top