Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / November 2005

Tip: Looking for answers? Try searching our database.

Code question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steve Voorhees - 18 Nov 2005 08:47 GMT
I am working on a database in which I will have different data types.  What I
want to be able to do is if, for example, the field [datatype] equals 1 it
would display a text box on the form, if 2 a combo box, if 3 a list box, etc.
Any suggestions?
Arvin Meyer [MVP] - 18 Nov 2005 10:15 GMT
In order to create controls in code, you must either open a form in Design
View, or have the controls in place and expose them at runtime.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access

> I am working on a database in which I will have different data types.  What I
> want to be able to do is if, for example, the field [datatype] equals 1 it
> would display a text box on the form, if 2 a combo box, if 3 a list box, etc.
> Any suggestions?
Steve Voorhees - 18 Nov 2005 10:37 GMT
I have written some code on controls before, but my problem is that I am not
sure how to do something of this nature, or even if it would be possible.

> In order to create controls in code, you must either open a form in Design
> View, or have the controls in place and expose them at runtime.
[quoted text clipped - 11 lines]
> etc.
> > Any suggestions?
Brendan Reynolds - 18 Nov 2005 11:05 GMT
You can create controls using the CreateControl method of the Form object,
but as Arvin says, you have to open the form in design view to do that. It's
generally better to create the controls in advance, and just toggle their
Visible property at run time. For example ...

Private Sub Form_Open(Cancel As Integer)

   Dim FieldType As Long

   FieldType = Me.Recordset.Fields(0).Type
   Select Case FieldType
   Case dbLong
       Me.Text28.Visible = True
       Me.Combo30.Visible = False
       Me.List32.Visible = False
   Case Else
       Me.Text28.Visible = False
       Me.Combo30.Visible = True
       Me.List32.Visible = True
   End Select

End Sub

Signature

Brendan Reynolds

>I have written some code on controls before, but my problem is that I am
>not
[quoted text clipped - 18 lines]
>> etc.
>> > Any suggestions?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.