views:

38

answers:

3

Hey everyone!

So my issue is that I want to have users enter their registration keys to a software into an Access table.

There are five parts to the registration key. How can I take these 5 boxes and format them to one column in the database?

(In Form: [_______] - [_______] - [_______] - [_______] - [_______]

In Database: "_______ - _______ - _______ - _______ - _______"

Many thanks,

Justian

+4  A: 

Why not just have five fields? It would be simpler for data entry/update purposes as these fields would then be found directly to the fields on the table. If you need them as one field for other purpses then in a query go soemthing like field1 & "-" & field2 & "-" & ...

Tony Toews
A: 

Didn't really get the answer I wanted. Creating multiple fields would just spread the data to multiple columns and I'd have to make 5 different calls (in a way) to the database to get that information.

It's just too messy. I ended up putting it in one column without the separate boxes.

Justian Meyer
A: 

If you do want to go back to five textboxes on the form, you can concatenate them in VBA:

strFullRegistrationNumber = TextBox1.Value & "-" & TextBox2.Value & "-" ...

Then to do the insert:

DoCmd.RunSQL "INSERT INTO MyTable (RegistrationKey) VALUES ('" & strFullRegistrationNumber & "')"

JohnK813
How can I access a VBA editor in Access? I'm totally new to it and have never custom-coded anything for it.
Justian Meyer
That being the case, the easiest thing is to stick with your solution. Otherwise, you're going to be doing a lot of unnecessary rewriting.That being said, if you're going to use a single field on your form, you may want to look into setting up an Input Mask for it.
JohnK813