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

Multiple fields in a single textbox

My database stores City and State in two separate columns, but I want
to display them on my form as a single field. Since I'm a complete VB
novice, I'm not sure how to do this. I bind the data, and I can bring
each field into my forn as a separate textbox. I created a third
textbox, and added code in the Form_Paint routine to concatenate the
fields:

CityStateTextBox.Text = CityTextBox.Text + ", " + StateTextBox.Text

This displayed just great, and the values were correct as I moved from
record to record with the PropertyBindingNavigator. I thought I could
just set the CityTextBox and StateTextBox to Visible = False in the
Properties window and I'd be done, but this causes the value in my
CityStateTextBox to disappear as well.

I know there must be some way to access the data values themselves for
the current row, rather than pulling them from text boxes, but I'm not
knowledgeable enough to figure it out myself. Any suggestions?

May 12 '06 #1
7 7217
Yes, the data is coming from a dataset which is filled from an
Addresses database. I have an AddressesDataset.xsd file in my project
which contains lines like

<Mapping SourceColumn="City" DataSetColumn="City" />
<Mapping SourceColumn="State" DataSetColumn="State" />

but I still don't know how to reference these in the Form code. Sorry
to be so ignorant; I'm not new to coding, but I am new to VB, and
trying to learn by doing. Thanks for your help.

May 12 '06 #2
rj
i also have this problem. what u can do (which is kinda corny, but it
works) is place a panel or label over the textboxes.
if you were using the oledataadapter to make the connection you could
also edit the select statement in the properties. this will bring up a
query window simillar to Ms Access query window and you could concat
the fields directly from there..

May 12 '06 #3
Spamicle.

The simplest (and best) way is creating that column while you are fetching
it using SQL.
An other method is to create an expression column.

http://www.vb-tips.com/default.aspx?...3-a3539697edbd

Dont be afraid for this sample, there is only something extra because it is
so simple.

Your expression is "FirstName + ' ' + LastName"

i hope this helps,

Cor

<sp********@gmail.com> schreef in bericht
news:11**********************@j73g2000cwa.googlegr oups.com...
My database stores City and State in two separate columns, but I want
to display them on my form as a single field. Since I'm a complete VB
novice, I'm not sure how to do this. I bind the data, and I can bring
each field into my forn as a separate textbox. I created a third
textbox, and added code in the Form_Paint routine to concatenate the
fields:

CityStateTextBox.Text = CityTextBox.Text + ", " + StateTextBox.Text

This displayed just great, and the values were correct as I moved from
record to record with the PropertyBindingNavigator. I thought I could
just set the CityTextBox and StateTextBox to Visible = False in the
Properties window and I'd be done, but this causes the value in my
CityStateTextBox to disappear as well.

I know there must be some way to access the data values themselves for
the current row, rather than pulling them from text boxes, but I'm not
knowledgeable enough to figure it out myself. Any suggestions?

May 12 '06 #4
That's a great suggestion, just cover up the "source" textboxes instead
of making them invisible. I played around with your idea, and I found
that if the "rollup" textbox is dragged onto the form after the
"source" textboxes, you can just make them all the same size and pile
them one on top of the other, and the textbox with the concatenated
data will be the one that displays. This doesn't require a panel or a
label, just cover them up with the textbox you want to display. The
only thing that seems to be required to make this work is dragging the
destination textbox onto the form after the source textboxes.

I don't have that oledataadapter in any form that I recognize. It
might be under the covers somewhere, but I don't see it. All I have is
"Me.Adapter"s in the Dataset.Designer.vb, and I don't see any select
statement for my textboxes in the Properties panel. I still think
there must be a way to get the value of the fields directly, rather
than ferrying them through intermediate textboxes, but we seem to have
stumped the experts here.

May 12 '06 #5
rj
oh yes piling them on top of 1 another is also fine.
did you code the connection?
I dont know how to do it like that. if you add an "oledbdataadapter" to
your form, you'll see it appear below the forms design.
right click it and select "configure data adapter"
follow the wizard.. you can concat that field you want in the wizards
select statement.
after that you create a dataset based on the table, and then link the
relevant textboxes in the items properties.

all the best!

May 12 '06 #6
Thanks, Cor and rj, your suggestions have enabled me to solve my
immediate problem and learn a little about how the data access pieces
all tie together in this development environment. I really appreciate
it.

May 12 '06 #7
Thanks, Cor and rj, your suggestions have enabled me to solve my
immediate problem and learn a little about how the data access pieces
all tie together in this development environment. I really appreciate
it.

May 12 '06 #8

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

Similar topics

7
by: Drew | last post by:
I have a db table like the following, UID, int auto-increment RegNo Person Relation YearsKnown Now here is some sample data from this table,
11
by: dskillingstad | last post by:
I've been struggling with this problem for some time and have tried multiple solutions with no luck. Let me start with, I'm a novice at Access and I'm not looking for someones help to design my...
22
by: Matthew Louden | last post by:
I want to know why C# doesnt support multiple inheritance? But why we can inherit multiple interfaces instead? I know this is the rule, but I dont understand why. Can anyone give me some concrete...
2
by: .Net Newbie | last post by:
Hello, I am currently coding my ASP.Net pages in c# and have run into a question concerning Emails. I have four objects on a page (six including 2 buttons). The first is a subject line...
12
by: shank | last post by:
I'm trying to use online samples for submitting multiple records from ASP into a stored procedure. Failing! Through the below form, a user could be submitting many records at a time. I'm not...
2
by: Matt | last post by:
Hi, I'm ridiculously new to Access (about a week!) so please be patient! My database is a record of British Standards. Each has a unique identifier. Some are split into parts. I would like...
8
by: JReneau35 | last post by:
I am a novice to MS Access. I have about 10 to 15 tables that link to a single form. I use unique ID's to link all of these tables together. Since the ID for the customer never changes, I was...
4
4Him
by: 4Him | last post by:
First off, let me say this is a great site! I've just started working with Access and much of my success is from what I've read here! Background: I have a form, driven off a single table. Goal:...
4
convexcube
by: convexcube | last post by:
Hi everyone, I am developing a database which amongst other things records contacts and related information. This database is structured so that a person can be an 'Employee', 'User', 'Customer'...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.