473,405 Members | 2,421 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,405 software developers and data experts.

Changing combo box to text box

Expand|Select|Wrap|Line Numbers
  1.  If Me.NewRecord = True Then
  2.  
  3.   Me.cmbCNum.Locked = False
  4.   Me.cmbSNum.Locked = False
  5.   Me.cmbCNum.Enabled = True
  6.   Me.cmbSNum.Enabled = True
  7.  
  8.   If Me.cmbCNum.ControlType = acTextBox Then
  9.    Me.cmbCNum.SetFocus
  10.    DoCmd.RunCommand acCmdChangeToComboBox
  11.   End If
  12.   If Me.cmbSNum.ControlType = acTextBox Then
  13.    Me.cmbSNum.SetFocus
  14.    DoCmd.RunCommand acCmdChangeToComboBox
  15.   End If
  16.  
  17.  Else
  18.  
  19.   If Me.cmbCNum.ControlType = acComboBox Then
  20.    docmd.openform("frmCSN", acDesign)
  21.    Me.cmbCNum.ControlType = acTextBox
  22.   End If
  23.   If Me.cmbSNum.ControlType = acComboBox Then
  24.    Me.cmbSNum.SetFocus
  25.    DoCmd.RunCommand acCmdChangeToTextBox
  26.   End If
  27.  
  28.   Me.cmbCNum.Locked = True
  29.   Me.cmbSNum.Locked = True
  30.   Me.cmbCNum.Enabled = False
  31.   Me.cmbSNum.Enabled = False
  32.  
  33.  End If
  34.  
What I want to do is change the combo box to a text box, and vice versa, depending if the form is on a new record or not. The rest of the code works, but the part for changing the type of box doesn't. It doesn't work if I use, for example,
Expand|Select|Wrap|Line Numbers
  1.   If Me.cmbSNum.ControlType = acComboBox Then
  2.    Me.cmbSNum.ControlType = acTextBox
  3.   End If
  4.  
either.

Help?
Allow Design Changes is set to all views.
Apr 29 '07 #1
10 12397
ADezii
8,834 Expert 8TB
Expand|Select|Wrap|Line Numbers
  1.  If Me.NewRecord = True Then
  2.  
  3.   Me.cmbCNum.Locked = False
  4.   Me.cmbSNum.Locked = False
  5.   Me.cmbCNum.Enabled = True
  6.   Me.cmbSNum.Enabled = True
  7.  
  8.   If Me.cmbCNum.ControlType = acTextBox Then
  9.    Me.cmbCNum.SetFocus
  10.    DoCmd.RunCommand acCmdChangeToComboBox
  11.   End If
  12.   If Me.cmbSNum.ControlType = acTextBox Then
  13.    Me.cmbSNum.SetFocus
  14.    DoCmd.RunCommand acCmdChangeToComboBox
  15.   End If
  16.  
  17.  Else
  18.  
  19.   If Me.cmbCNum.ControlType = acComboBox Then
  20.    docmd.openform("frmCSN", acDesign)
  21.    Me.cmbCNum.ControlType = acTextBox
  22.   End If
  23.   If Me.cmbSNum.ControlType = acComboBox Then
  24.    Me.cmbSNum.SetFocus
  25.    DoCmd.RunCommand acCmdChangeToTextBox
  26.   End If
  27.  
  28.   Me.cmbCNum.Locked = True
  29.   Me.cmbSNum.Locked = True
  30.   Me.cmbCNum.Enabled = False
  31.   Me.cmbSNum.Enabled = False
  32.  
  33.  End If
  34.  
What I want to do is change the combo box to a text box, and vice versa, depending if the form is on a new record or not. The rest of the code works, but the part for changing the type of box doesn't. It doesn't work if I use, for example,
Expand|Select|Wrap|Line Numbers
  1.   If Me.cmbSNum.ControlType = acComboBox Then
  2.    Me.cmbSNum.ControlType = acTextBox
  3.   End If
  4.  
either.

Help?
Allow Design Changes is set to all views.
What I want to do is change the combo box to a text box, and vice versa, depending if the form is on a new record or not. The rest of the code works, but the part for changing the type of box doesn't.
The only time you can programmatically change the type of any Control is when you are in Design Mode for the Parent Container.
Apr 29 '07 #2
The only time you can programmatically change the type of any Control is when you are in Design Mode for the Parent Container.
can I do that in code?

edit: by the way that went straight over my head!
Apr 29 '07 #3
Noticed another point;
The first If... in the Else... statement won't work. If that worked would I be able to change it to a text box?
Apr 29 '07 #4
ADezii
8,834 Expert 8TB
can I do that in code?

edit: by the way that went straight over my head!
]can I do that in code?
I doubt it very much since you would need to be able to determine if you are on a New Record or not. This obviously is not possible if the Form is in Design Mode. I'm sure other Moderators/Expert will look in and give their opinion also.
Apr 29 '07 #5
Expand|Select|Wrap|Line Numbers
  1. Sub Form_Current()
  2.  
  3.  Dim rcdCSN As Long
  4.  
  5.  If Me.NewRecord = True Then
  6.   If Me.cmbCNum.ControlType = acComboBox Then
  7.    rcdCSN = Form.CurrentRecord
  8.    DoCmd.Close acForm, "frmCSN", acSaveYes
  9.    DoCmd.OpenForm "frmCSN", acDesign
  10.    Forms!frmCSN!cmbCNum.ControlType = acTextBox
  11.    DoCmd.Close acForm, frmCSN, acSavePrompt
  12.    DoCmd.OpenForm "frmCSN"
  13.    Me.CurrentRecord = rcdCSN
  14.   End If
  15.   End If
  16.  
  17. End Sub
  18.  
??
But the variable rcdCSN won't set.
Apr 30 '07 #6
ADezii
8,834 Expert 8TB
Expand|Select|Wrap|Line Numbers
  1. Sub Form_Current()
  2.  
  3.  Dim rcdCSN As Long
  4.  
  5.  If Me.NewRecord = True Then
  6.   If Me.cmbCNum.ControlType = acComboBox Then
  7.    rcdCSN = Form.CurrentRecord
  8.    DoCmd.Close acForm, "frmCSN", acSaveYes
  9.    DoCmd.OpenForm "frmCSN", acDesign
  10.    Forms!frmCSN!cmbCNum.ControlType = acTextBox
  11.    DoCmd.Close acForm, frmCSN, acSavePrompt
  12.    DoCmd.OpenForm "frmCSN"
  13.    Me.CurrentRecord = rcdCSN
  14.   End If
  15.   End If
  16.  
  17. End Sub
  18.  
??
But the variable rcdCSN won't set.
Forget about rcdCSN, it goes out of scope as soon as the 1st Instance of frmCSN is closed since it is Local to the Form's Current() Event. The CurrentRecord Event is Read Only, you can only Read its value, you cannot assign the Current Record of a Form to a value.
Apr 30 '07 #7
pah I gave up, I'll settle with the little arrow being there...
Apr 30 '07 #8
ADezii
8,834 Expert 8TB
pah I gave up, I'll settle with the little arrow being there...
Never give up - just try a different approach.
Apr 30 '07 #9
I placed a text box over the combo box in the end, and just acitvate them depending on which I want
May 1 '07 #10
ADezii
8,834 Expert 8TB
I placed a text box over the combo box in the end, and just acitvate them depending on which I want
Just what I was talking about - a different approach!
May 1 '07 #11

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

Similar topics

1
by: VINAY | last post by:
Dear All, The subject line could be bit confusing. So let me explain in details, please have patience. I have developed an ActiveX Control(Combo Box Control) in VB6 for a touch screen...
3
by: MS | last post by:
What's the best way to "store" and display a value in a text box that changes from day to day. An example of this would be where the name of the user is manually typed in after using the datbase,...
3
by: Doug | last post by:
Hi I have the following code (not mine) that populates a datagrid with some file names. But I want to replace the datagrid with a combo box. private void OnCurrentDataCellChanged(object sender,...
7
by: Arnold | last post by:
Greetings Gurus, In a mainform's header, I have a combobox named comboStudents. The rowsource for this combobox is: SELECT -999 As StudentID, "<Add New Student>" As FullName, "aaa" As...
3
by: jegadeep | last post by:
In a JSP page there are one combo box and one text feild..... Change in one combo box will have hit the database .... And get values from that , populate the corresponding values in the text...
3
by: vinodkus | last post by:
dear sir/madam I have a combo which has 2 values I want when its value is changed then its value should be display in a text box. Thanks In Advance
8
by: jmartmem | last post by:
Greetings, I have an Access 2002 continuous form called "Project Update Form" in which users can update project values presented in a series of combo boxes and text boxes. I have three combo boxes...
3
by: pipeme | last post by:
Hi I am using Access 2003 and I have a form with 120 textboxes in a grid layout. Depending on a selection made in a combo box, I want to change the visibility of certain textboxes in the grid. ...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.