473,725 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

populate combo with field-caption-names of a table

Dear all,

How can i populate a combo with the field-caption-names of 1 table?

Thanks

Filip
Nov 13 '05 #1
5 2453
Filips Benoit wrote:
Dear all,

How can i populate a combo with the field-caption-names of 1 table?


Set the RowSourceType of the combo to "Field List"

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea
Nov 13 '05 #2
Field-caption not fieldnames.

Filip

"Bas Cost Budde" <b.*********@he uvelqop.nl> wrote in message
news:cq******** **@news2.solcon .nl...
Filips Benoit wrote:
Dear all,

How can i populate a combo with the field-caption-names of 1 table?


Set the RowSourceType of the combo to "Field List"

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea

Nov 13 '05 #3
Filips Benoit wrote:
Field-caption not fieldnames.


Oh! Sometimes I read sloppy.

Can you live with a function that reads the captions (from the table
definition I presume) and returns a semicolon separated string?

Function getFieldCaption s(cTable As String) As String
Dim cRes As String
Dim db As DAO.Database
Dim td As DAO.TableDef
Dim fd As DAO.Field
On Error Resume Next
Set db = CurrentDb
Set td = db.TableDefs(cT able)
For Each fd In td.Fields
cRes = cRes & fd.Properties(" Caption") & ";"
If Err = 3270 Then
Err = 0
cRes = cRes & fd.Name & ";"
End If
Next
Set td = Nothing
getFieldCaption s = Left(cRes, Len(cRes) - 1)
Set db = Nothing
End Function

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea
Nov 13 '05 #4
thanks²

"Chuck Grimsby" <c.*******@worl dnet.att.net.in valid> wrote in message
news:u7******** *************** *********@4ax.c om...
On Sat, 18 Dec 2004 15:08:58 GMT, "Filips Benoit"
<be***********@ pandora.be> wrote:
How can i populate a combo with the field-caption-names of 1 table?


In the form's code module, put the code below, adjusting the name of
the table and the combo box's name to be whatever the heck you need it
to be:

Private Sub Form_Load()
Dim strTemp As String
strTemp = FieldCaptionsOf ATable("MyTable ")
Me.myCombo.RowS ource = strTemp
End Sub

Private Function FieldCaptionsOf ATable( _
strTableName As String) _
As String
Dim myDB As DAO.Database
Dim TDF As DAO.TableDef
Dim FLD As DAO.Field
Dim strCaptions As String

Set myDB = CurrentDb
Set TDF = myDB.TableDefs( strTableName)
On Error Resume Next

For Each FLD In TDF.Fields
strCaptions = strCaptions & ";" & _
Chr$(34) & FLD.Properties( "Caption") & Chr$(34)
Select Case Err.Number
Case 0
' do nothing, no error occured.
Case 3270
' No caption, so use the field name:
strCaptions = strCaptions & ";" & _
Chr$(34) & FLD.Properties( "Name") & Chr$(34)
End Select
Err.Clear
Next
On Error GoTo 0
FieldCaptionsOf ATable = Mid$(strCaption s, 2)
End Function
--
Shell To Dos... Come In Dos... Do You Copy?

Nov 13 '05 #5
Chuck Grimsby wrote:
Hope you didn't mind my post to the thread, Bas.
Not at all, not at all!
It was, for me anyways, interesting to see how similar our code was!
And for me. I like your Mid(st,2) because that at least looks less
cluttered than left(st,len(st)-1)--and I figure it executes smoother.
Other languages have constructs to leave out the last n characters, alas
VB hasn't.
For what it's worth, you're also going to need to put double quotes
(Chr$(34) around the captions to get them to show up in the list.
Unless you know something I don't?


I probably confused this with something else. They must be literals of
course.

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea
Nov 13 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
3551
by: Support4John | last post by:
a2k (9.0.6926) SP-3 Jet 4.0 SP-7 I have a form with combo box field that allows the user to select from the combo box or type in the field value that may or maynot be in the combo box field. In the After Update Event of the combo box field how can I tell if the field value was selected from open combo box or typed in by the user? Thanks, John
4
12844
by: godber | last post by:
I need to populate text boxes for instance with employee information using their unique employee works number selected from a combo box. Can anyone help, I am told thru visual basic this can be achieved.
4
3004
by: Mike L | last post by:
I'm open for any suggestions on how to better program this. I want the user to select a license from a combo box, cboPrivilege and then the user will click the add button, then a record will be added to the data grid. My current code is coming up with errors, dt and drv are unknown in the else part of the if statement. if (this.dgPrivileges.DataSource == null) {
11
12306
by: DSR | last post by:
Help Please... I would like to populate a combo box on a form with a query that compares data from two tables. Any record that is unique in table1 should continue to populate my combobox. The instant the record appears also in table2 it should no longer be listed in my combo box. This is not a key field in either of the tables. Basically what I am trying to do is prevent the user from entering duplicate values even though it is not a key...
16
10527
by: agrawal.solutions | last post by:
Hello Friends I am asking a very silly question but i dont find any solution fo this.. I am selectiong a recordset and want to populate a combobox where id would be inviseble and the content would. I am getting the recordset and the no of record but then i am unble to populate the combobox. I have already tried all the function starting form for each x in .... and while...wend and do....loop
3
11274
by: David | last post by:
I am trying to use Dlookup to populate a text box on a form, but haven't had any good luck so far. I've looked here at the posts and have used the Access help for examples. Northwind is way over my head. I think that I'm coming up short in the Criteria part of the function. I have a combo box that looks to the 'Student' table, 'Student_ID' field to list the students, and then places the selected value in the 'Student_ID' text box on...
1
1598
by: indhu | last post by:
Hi all, I want 2 know, how to populate using 2 combo box to populate other field. right now am using click event of combo to populate the other field but i want to select both combo1 and combo2 when these 2 r equal then it populate other fields. Private Sub scene_txt_Click() 'combo name scene_Txt
2
1648
by: Robertjb1 | last post by:
First Post - New member - I've searched the discussions available to no avail. I have, however, learned a few things in doing so. (Great Site -- Thanks) My issue is as follows: Access 2003/WinXP I have created a task tracking database. On the main form, I have placed two combo boxes. The first (cboContact) lists the user that the task is assigned to. record source = SELECT Contacts.ID, Contacts. FROM Contacts ORDER BY Contacts.;
3
1057
by: PGM | last post by:
I am trying to populate a combo box using a simple SQL query to a database but all I get in the combo box is "System._ComObject" . Any suggestions are greatly appreciated On Error Resume Next Dim strSQL As String Dim strConn As String
1
3186
by: cluless | last post by:
Hey everybody, I have a database with one major form that has a few subforms and a listbox, and on the form there are buttons that link to other forms as well. Once the list box is clicked on, the four subforms automatically populate based on the selection. The buttons that link to the other forms are designed to begin to add a record (based on what subform button was pressed). I want to find a way for the first field in the newly opened...
0
8752
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9257
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9174
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6702
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4517
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4782
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3221
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2634
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.