Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2004-08-09
5
Medium Priority
?
173 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 1500 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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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 process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

886 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