I want to know how to reference the form properties of these sub forms. This I can do but what I am having trouble with is substituting the form name with a variable.
Below is what I have that works
Expand|Select|Wrap|Line Numbers
- groupHeight = 0
- FormHeader = stdHeader
- formDetail = stdDetail
- FormFooter = stdFooter
- ' Count Number of Records
- Set dbs = CurrentDb
- strSQL = "SELECT FitmentChart.FitmentMakeID, FitmentChart.FitmentTypeID, FitmentChart.FitmentModelID, Products.DisContinued, Products.Superceded, Products.CanBeSold, FitmentChart.FitmentPartTypeID FROM Products INNER JOIN (FitmentLocation INNER JOIN (FitmentPartType INNER JOIN FitmentChart ON FitmentPartType.FitmentPartTypeID = FitmentChart.FitmentPartTypeID) ON FitmentLocation.FitmentLocationID = FitmentChart.FitmentLocationID) ON Products.ID = FitmentChart.ProductCodeID WHERE (((FitmentChart.FitmentMakeID)= " & [Forms]![VehicleSearch]![LookupMake] & ") AND ((FitmentChart.FitmentTypeID)= " & [Forms]![VehicleSearch]![LookupType] & ") AND ((FitmentChart.FitmentModelID)= " & [Forms]![VehicleSearch]![LookupModel] & ") AND ((Products.DisContinued)=False) AND ((Products.Superceded)=False) AND ((Products.CanBeSold)=True) AND ((FitmentChart.FitmentPartTypeID)=14));"
- Set rst = dbs.OpenRecordset(strSQL)
- Do Until rst.EOF
- groupHeight = groupHeight + 1
- rst.MoveNext
- Loop
- rst.Close
- Set dbs = Nothing
- If groupHeight > 0 Then
- groupHeight = FormHeader + (formDetail * groupHeight) + FormFooter
- Me.VehicleSearchLabour.Top = groupTop * twipExchange
- Me.VehicleSearchLabour.Height = groupHeight * twipExchange
- Forms!VehicleSearch!VehicleSearchLabour.Requery
- groupTop = groupTop + groupHeight
- Me.VehicleSearchLabour.Visible = True
- Else
- Me.VehicleSearchLabour.Top = groupTop * twipExchange
- Me.VehicleSearchLabour.Height = groupHeight * twipExchange
- Me.VehicleSearchLabour.Visible = True
- End If
Expand|Select|Wrap|Line Numbers
- Dim dbsLoop As Database, rstLoop As Recordset
- Dim strSQLloop As String
- Set dbsLoop = CurrentDb
- strSQLloop = "SELECT FitmentPartType.FitmentPartTypeID, FitmentPartType.VehicleSearchOrder, FitmentPartType.Description, FitmentPartType.VehicleSearchForm FROM FitmentPartType ORDER BY FitmentPartType.VehicleSearchOrder;"
- Set rstLoop = dbsLoop.OpenRecordset(strSQLloop)
- Do Until rstLoop.EOF
- Dim dbs As Database, rst As Recordset
- Dim strSQL As String
- Dim groupTop, groupHeight, FormHeader, formDetail, FormFooter, stdHeader, stdDetail, stdFooter As Integer
- Dim twipExchange As Double
- twipExchange = 566.929
- groupTop = 0
- stdHeader = 1
- stdDetail = 0.75
- stdFooter = 0.1
- groupHeight = 0
- FormHeader = stdHeader
- formDetail = stdDetail
- FormFooter = stdFooter
- Set dbs = CurrentDb
- strSQL = "SELECT FitmentChart.FitmentMakeID, FitmentChart.FitmentTypeID, FitmentChart.FitmentModelID, Products.DisContinued, Products.Superceded, Products.CanBeSold, FitmentChart.FitmentPartTypeID FROM Products INNER JOIN (FitmentLocation INNER JOIN (FitmentPartType INNER JOIN FitmentChart ON FitmentPartType.FitmentPartTypeID = FitmentChart.FitmentPartTypeID) ON FitmentLocation.FitmentLocationID = FitmentChart.FitmentLocationID) ON Products.ID = FitmentChart.ProductCodeID WHERE (((FitmentChart.FitmentMakeID)= " & [Forms]![VehicleSearch]![LookupMake] & ") AND ((FitmentChart.FitmentTypeID)= " & [Forms]![VehicleSearch]![LookupType] & ") AND ((FitmentChart.FitmentModelID)= " & [Forms]![VehicleSearch]![LookupModel] & ") AND ((Products.DisContinued)=False) AND ((Products.Superceded)=False) AND ((Products.CanBeSold)=True) AND ((FitmentChart.FitmentPartTypeID)= " & rstLoop![FitmentPartTypeID] & "));"
- Set rst = dbs.OpenRecordset(strSQL)
- Do Until rst.EOF
- groupHeight = groupHeight + 1
- rst.MoveNext
- Loop
- rst.Close
- Set dbs = Nothing
- If groupHeight > 0 Then
- groupHeight = FormHeader + (formDetail * groupHeight) + FormFooter
- rstLoop![VehicleSearchform].Top = groupTop * twipExchange
- rstLoop![VehicleSearchForm].Height = groupHeight * twipExchange
- rstLoop![VehicleSearchForm].Requery
- groupTop = groupTop + groupHeight
- rstLoop![VehicleSearchForm].Visible = True
- Else
- rstLoop![VehicleSearchForm].Top = groupTop * twipExchange
- rstLoop![VehicleSearchForm].Height = groupHeight * twipExchange
- rstLoop![VehicleSearchForm].Visible = True
- End If
- rstLoop.MoveNext
- Loop
- rstLoop.Close
- Set dbsLoop = Nothing