473,394 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Referencing Subform Properties using Variables

I have a form that has 5 sub forms on it.

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
  1.     groupHeight = 0
  2.     FormHeader = stdHeader
  3.     formDetail = stdDetail
  4.     FormFooter = stdFooter
  5.     ' Count Number of Records
  6.     Set dbs = CurrentDb
  7.     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));"
  8.     Set rst = dbs.OpenRecordset(strSQL)
  9.     Do Until rst.EOF
  10.         groupHeight = groupHeight + 1
  11.         rst.MoveNext
  12.     Loop
  13.     rst.Close
  14.     Set dbs = Nothing
  15.     If groupHeight > 0 Then
  16.         groupHeight = FormHeader + (formDetail * groupHeight) + FormFooter
  17.         Me.VehicleSearchLabour.Top = groupTop * twipExchange
  18.         Me.VehicleSearchLabour.Height = groupHeight * twipExchange
  19.         Forms!VehicleSearch!VehicleSearchLabour.Requery
  20.         groupTop = groupTop + groupHeight
  21.         Me.VehicleSearchLabour.Visible = True
  22.     Else
  23.         Me.VehicleSearchLabour.Top = groupTop * twipExchange
  24.         Me.VehicleSearchLabour.Height = groupHeight * twipExchange
  25.         Me.VehicleSearchLabour.Visible = True
  26.     End If
  27.  
Below is what I have tried but does not work

Expand|Select|Wrap|Line Numbers
  1.  
  2.     Dim dbsLoop As Database, rstLoop As Recordset
  3.     Dim strSQLloop As String
  4.     Set dbsLoop = CurrentDb
  5.     strSQLloop = "SELECT FitmentPartType.FitmentPartTypeID, FitmentPartType.VehicleSearchOrder, FitmentPartType.Description, FitmentPartType.VehicleSearchForm FROM FitmentPartType ORDER BY FitmentPartType.VehicleSearchOrder;"
  6.     Set rstLoop = dbsLoop.OpenRecordset(strSQLloop)
  7.     Do Until rstLoop.EOF
  8.  
  9.         Dim dbs As Database, rst As Recordset
  10.         Dim strSQL As String
  11.         Dim groupTop, groupHeight, FormHeader, formDetail, FormFooter, stdHeader, stdDetail, stdFooter As Integer
  12.         Dim twipExchange As Double
  13.         twipExchange = 566.929
  14.         groupTop = 0
  15.         stdHeader = 1
  16.         stdDetail = 0.75
  17.         stdFooter = 0.1
  18.         groupHeight = 0
  19.         FormHeader = stdHeader
  20.         formDetail = stdDetail
  21.         FormFooter = stdFooter
  22.         Set dbs = CurrentDb
  23.         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] & "));"
  24.         Set rst = dbs.OpenRecordset(strSQL)
  25.         Do Until rst.EOF
  26.             groupHeight = groupHeight + 1
  27.             rst.MoveNext
  28.         Loop
  29.         rst.Close
  30.         Set dbs = Nothing
  31.         If groupHeight > 0 Then
  32.             groupHeight = FormHeader + (formDetail * groupHeight) + FormFooter
  33.             rstLoop![VehicleSearchform].Top = groupTop * twipExchange
  34.             rstLoop![VehicleSearchForm].Height = groupHeight * twipExchange
  35.             rstLoop![VehicleSearchForm].Requery
  36.             groupTop = groupTop + groupHeight
  37.             rstLoop![VehicleSearchForm].Visible = True
  38.         Else
  39.             rstLoop![VehicleSearchForm].Top = groupTop * twipExchange
  40.             rstLoop![VehicleSearchForm].Height = groupHeight * twipExchange
  41.             rstLoop![VehicleSearchForm].Visible = True
  42.         End If
  43.         rstLoop.MoveNext
  44.     Loop
  45.     rstLoop.Close
  46.     Set dbsLoop = Nothing
  47.  
  48.  
Basically I have a table named 'FitmentPartType' that contains a field called 'VehicleSearchForm' that holds the names of the sub forms on my form. The code steps through this table and is suppose to show / hide and adjust position properties of the sub form that each record refers to.
Jun 28 '07 #1
3 2178
MMcCarthy
14,534 Expert Mod 8TB
The only thing I can think of offhand is to have just one subform object (sfrmObject) and change it dynamically.

Me.sfrmObject.SourceObject = rstLoop![VehicleSearchForm]

' you will have to add these to the recordset
Me.sfrmObject.LinkMasterFields = rstLoop!MasterID
Me.sfrmObject.LinkChildFields = rstLoop!ChildID

Me.sfrmObject.Top = groupTop * twipExchange

etc.
Jun 29 '07 #2
Thanks for your reply.

I tried your suggestion and must admit it didn't mean much to me as I am only just starting to use record sets. It also quite possibly could have been my explination.

I had another suggestion on another forum and it worked.

Me(rstLoop![VehicleSearchForm]).Top = groupTop * twipExchange

I had tried this with me. but had no success. So it must be that when you use brackets it takes the contents as a variable not characters to find and therefore looks up the variable contents.
Jul 1 '07 #3
MMcCarthy
14,534 Expert Mod 8TB
Thanks for your reply.

I tried your suggestion and must admit it didn't mean much to me as I am only just starting to use record sets. It also quite possibly could have been my explination.

I had another suggestion on another forum and it worked.

Me(rstLoop![VehicleSearchForm]).Top = groupTop * twipExchange

I had tried this with me. but had no success. So it must be that when you use brackets it takes the contents as a variable not characters to find and therefore looks up the variable contents.
When you use brackets it takes a string value. Your problem earlier was you were trying to directly refer to the subform control with a string.
Jul 2 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: chrisM | last post by:
Hi, Hope someone can help me. I have the following setup in an Access database A master form 'Customers' in 'Single Form' view that has a RecordSource of 'myCustomerTable' CustomerCode...
2
by: William Wisnieski | last post by:
Hello Everyone, Access 2000 I have a main form with a continuous subform. On the main form I have a text box that references a field on the subform. What I'd like it to do is show the value...
25
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the...
3
by: shumaker | last post by:
This code from the subform works for getting the value of a field of the main form named "WorkSheet": MsgBox Form_WorkSheet.Recordset.Fields("Clerk").Value Each record in the mainform datasheet...
6
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header"...
2
by: Axel | last post by:
Hi, a question about something that seems very simple at first glance: is it possible to reference other controls of a subform in a query window without referencing through the parent form? I...
9
by: Alan | last post by:
Hmmm, I'm not too good with the syntax of referencing a subreport. I have frmInvoice which has the invoice details (e.g. ProductCode, ProductCost etc) in the subform frmInvoiceDetails. I'm trying...
14
by: Kurt | last post by:
I have an unbound main form with an unbound subform. frmProjects fsubProjectList Using combo boxes, the user can select several search criteria on frmProjects and then click a command button....
21
by: cmd | last post by:
I have code in the OnExit event of a control on a subform. The code works properly in this instance. If, however, I put the same code in the OnExit event of a control on a Tab Control of a main...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.