?
Solved

Visual Basic Arrays and Access Database

Posted on 2003-11-11
6
Medium Priority
?
345 Views
Last Modified: 2013-11-25
I have a column in my access database table called "Lines", and I need it to be an array type somehow so that for each record in the table I can have multiple "Lines" and for each "Line" I can store an X1, Y1, X2, Y2.  Also, how would I use a select statement and update statement from visual basic to access and update that field?  I know I could just create a whole new table to do this for me, but would perfer not too.  I don't know a lot about access, use it rarely, so I'm sure is something beyond the basics I know to accomplish this.

Thanks, Jebus
0
Comment
Question by:dj__jebus
  • 3
4 Comments
 

Author Comment

by:dj__jebus
ID: 9726774
I just found the menu thing insert a subdatasheet.  Is this along the lines if something I could use?  How does it work and how would I implement it in my vb project to make it work?  Or is it completely unrelated?

Thanks Jebus
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 9726907
How about adding them to the field seperated by a carraiage return:

' add a refence to Microsoft ActiveX Data Objects Library:

Dim DataBase As String
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
DataBase = "C:\MyDataBase"

' open Database Connection
Set cn = New ADODB.Connection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" & DataBase & "'"
cn.CursorLocation = adUseClient
cn.Open

' open recordset
Set rs = New ADODB.Recordset
rs.Open "Select * From MyTable", cn, adOpenKeyset, adLockOptimistic

' add new record to Table
rs.AddNew
rs.Fields("Lines").Value = X1 & vbCr & X2 & vbCr & Y1 & vbCr & Y2
rs.Update

' update current record
rs.Fields("Lines").Value = X1 & vbCr & X2 & vbCr & Y1 & vbCr & Y2
rs.Update

' close recordset
rs.Close
Set rs = Nothing

' close connection
cn.Close
Set cn = Nothing


0
 

Author Comment

by:dj__jebus
ID: 9727271
I would like to try using this subdatasheet thing.  I have a table called "Jobs" in which I have a subdatasheet called "Walls"  In Walls I have my WallID, X1, Y1, X2, Y2 columns.  So all I need now is to write my sql string to be able to select and update things from the Walls table for each record in Jobs.

Thanks Jebus
0
 

Accepted Solution

by:
dj__jebus earned 0 total points
ID: 9744514
Well, I figured it out on my own.  I just made another table for Walls and used the relations thing in access.  I then used a normal select statement with a where JobID=blah  thing.

Thanks, Jebus
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question