Solved

Visual Basic Arrays and Access Database

Posted on 2003-11-11
6
335 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
6 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now