Solved

(VB6) ActiveX Control in FoxPro6. How do I connect to the data?

Posted on 2004-08-09
5
163 Views
Last Modified: 2010-05-02
I created an ActiveX Calendar Control in VB. (Because all the other ones are ugly)

Everything is going great... Except the fact that it's just pretty, and does nothing useful...

Project: Create an Inventory Management program using FoxPro6 (gag)
Current Task: Create a Calendar that shows the number of chairs instock on each day. (Vb6 ActiveX Custom Control, OCX)
Brick Wall: It looks pretty, but doesn't connect to the data.

The goal of the Calendar (and the real reason I made it in the first place) is to count up all the available items on a certain day and display the Inventory Status on each day in a month view.

<img src="http://winstormsolutions.com/myreallycoolcalendar.jpg">
(ignore the random button, that's my test database connection button..)

The calendar and internal math work great -- But use random data!

Assuming I know everything about VB worth knowing (Except Database connectivity) How in the world do I go about connecting to a FoxPro6 database. Here is the Catch -- I'd like to be able to reuse it. Adding a special property used this way:

(This is how i'd like for it to be used)

objCalendar.RecordType = "Fox Pro 6"
objCalendar.RecordSource = "Inventory!Category"
objCalendar.UpdateUI
Or whatever, but you get the idea. Maybe auto updating, or whatever.

I don't know which references i'd need, and i prefer not to have any extra required files. I'd prefer the program to work on Windows 95 WITHOUT MDAC 2.5 (or whatever we're up to now..)

I'd like to use the data control that comes with VB6.

The data is READONLY, I can't imagine the calendar changing anything, but if you can put together some two way street that'd be fine.

Name of the game is REUSABLE.. No hardcoding the paths or database types.

I'd give it a 5,000 rating, but I hear that's frowned upon..

Cheers,

-Michael Smyers
Anderson Enterprises
0
Comment
Question by:Anderson_Enterprises
  • 4
5 Comments
 
LVL 9

Accepted Solution

by:
samopal earned 500 total points
ID: 11758386
1) Do you have any experience with FoxPro?
2) You need the way to pass data from main application (VFP) to your control. I see 3 choices :
- pass this data as string (or file) and parse it in VB control
- pass data as ADO recordset (and I prefer this)
- pass the link to your DBF database into VB control
last 2 options will require MDAC install on client computer

For the second option :

add objCalendar.RecordSource property as ADODB.Recordset into your control and build all calculations inside VB control based on this recordset

in VFP application select required data into cursor and use this sample from M$ to convert VFP cursor into ADODB recordset
http://download.microsoft.com/download/vfox60/samp3/1/WIN98/EN-US/RS2dbf.exe
After that just assign result ADO recordset to the RecordSource property of your control.

Hope This Helps,
D'Al
0
 

Author Comment

by:Anderson_Enterprises
ID: 11759091
Hmm, How do I go about doing 2.b

I prefer no extra step in the transfer of data. It needs to be smooth and easy.

I am accustomed to such things as:

myConn.Open ""
myConn.Execute ""

etc..
0
 

Author Comment

by:Anderson_Enterprises
ID: 11759098
oh yea, i'd like to get the data like this..

MyVariable = MyTable("MyField")
0
 

Author Comment

by:Anderson_Enterprises
ID: 11763362
I created an ODBC connection in the control panel, and then used JET to connect to it..

I'm going to award you the points, because I did get the answer reading along the suggested lines.

Thanks!
0
 

Author Comment

by:Anderson_Enterprises
ID: 11763370
Msgbox(Data1.RecordSet.Fields("MyField"))
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

762 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

21 Experts available now in Live!

Get 1:1 Help Now