473,385 Members | 1,890 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,385 software developers and data experts.

Set subform visibile on specific criteria

Hello,

I need to know if in VB it is possible to set a subform that is visible sometimes and others invisible, to a selected record. For example on a separate Cmd click I have a separate form open up with the selected record. The code reads:

DoCmd.OpenForm "frm_contactsEdit", , , "[ContactID]=" & Me.ListContact

I need my visible comand to follow a similar procedure of setting to a specific record. It is not possible to link the subform and from because my form is not bound to any object.

Any help would be appreciated.

Oxford Consulting
May 29 '07 #1
3 1282
MMcCarthy
14,534 Expert Mod 8TB
Something like this in the After Update event of the list should work ...
Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub ListContact_AfterUpdate()
  3.     If nz(DLookup("[ContactID]", "TableName", "[ContactID]=" & Me.ListContact),"") = "" Then
  4.        Me!SubformObjectName.Visible = False
  5.        Me!SubformObjectName.Filter = ""
  6.        Me!SubformObjectName.FilterOn = False
  7.     Else
  8.        Me!SubformObjectName.Visible = True
  9.        Me!SubformObjectName.Filter = "[ContactID]=" & Me.ListContact
  10.        Me!SubformObjectName.FilterOn = True
  11.     End If
  12.  
  13. End Sub
  14.  
Jun 1 '07 #2
I tried this technique, using Access 2003 with SP3. Apparently the interpreter thinks that the subform name is the name of a field on the form. It throws an error message 2465, "Microsoft Access Cant find the field 'NameOfSubForm' referred to in your expression". Any other ideas anyone?
Expand|Select|Wrap|Line Numbers
  1. Private Sub SetVisibles()
  2.     Select Case cboAssessType
  3.         Case "G" ' General Education
  4.             Me!frmGenEdCoreReqs.Visible = True
  5.         Case Else
  6.             Me!frmGenEdCoreReqs.Visible = False
  7.     End Select
  8. End Sub
  9.  
Nov 8 '07 #3
Never mind! Still part of the old school that think any time I am referring to a form, I need the Bang as the separator. Substituting the dot for the bang in my code worked just great!
Nov 8 '07 #4

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

Similar topics

4
by: Dave Boyd | last post by:
Hi, I have two very similar forms each with a subform. The main form gets a few fields from the user and passes this back to a query that the subform is bound to. The requery is done when the...
5
by: tdmailbox | last post by:
I have a form with a child form. In the child form there is a list of names that can grow quite large. On the parent form I want to display the first name from the child form. I set up a test...
3
by: matthewemiclea | last post by:
So I think this may be a stretch, but I have a subform that is displayed on a main form. The subform is based on a query that brings records from a table(It does not bring all fields, but the main...
2
by: Shiva | last post by:
Hi, I wonder if it is possible to filter a subform in Access 2002. In other words, the selection criteria of the filter are defined by the fields of the subform. This doesn't seem to work....
9
by: PC Datasheet | last post by:
I'm stuck on something that seems should be easy and I need some help. My main form has an option group with five options. My subform chooses from different lists depending on which option is...
3
by: dhowell | last post by:
In reading some of the posts on this group, it appears as though it is not strait forward at all to filter a form, which has subforms, by criteria which are either on subforms or span more than one...
1
by: bcreighton | last post by:
I have created a bound subform on an unbound masterform linked together with a common field (A store's identification number) using an unbound combobox on the masterform and an invisible field on...
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....
6
by: Dave | last post by:
I want to put the information that the user selects in my combo boxes into a subform that lies on the same form as the combo boxes. Thanks for your help already, Dave
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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,...

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.