Code problem

I am using some modified code from a project I wrote 3 years ago and and having problems with it,

In the App event open I have

[code]// Create Database Object
Dim golfer as RealSQLDatabase
golfer = New REALSQLDatabase

dim f as folderitem = specialFolder.ApplicationData.Child(“TGC”)
if f.exists = false then
f.createasfolder
end

f = f.child(“Golf”)
if f.exists = false then
f.createasfolder
end

f = f.child(“golfer.rsd”)
golfer.DatabaseFile = f

// Set Database File
golfer.DatabaseFile = SpecialFolder.ApplicationData.Child(“TGC”).Child(“Golf”).Child(“golfer.rsd”)

// Connect to the database
if golfer.databaseFile.exists = true then
// The database file already exists, so we want to connect to it.
if golfer.Connect() = false then
DisplayDatabaseError//( false )// there was an error connecting to the database
Quit
return
end if
else
// The database file does not exist so we want to create a new one.
// The process of creating a database will establish a connection to it
// so there isn’t a need to call Database.Connect after we create it.

CreateDatabaseFile    

end

// Set the application to AutoQuit, so if all windows are closed then the application
// will quit.
app.autoQuit = true [/code]

I also have 2 Methods

  1. CreateDatabaseFile

if golfer.CreateDatabaseFile = false then // Error While Creating the Database MsgBox "Database Error" + EndOfLine + EndOfLine + "There was an error when creating the database." Quit end if golfer.SQLExecute "CREATE TABLE data(PK INTEGER PRIMARY KEY NOT NULL ,FirstName, Lastname)" golfer.Commit

  1. DisplaDatabaseError
MsgBox "Database Error: " + str(golfer.ErrorCode) + EndOfLine + EndOfLine + golfer.ErrorMessage 

The problem I am having is with “golfer” in the 2 Methods all instances keep coming up as they don’t exist and I can’t find the problem.

Thanks Shane

In your definition of golfer, RealSQLDatabase should be SQLiteDatabase
(I think that should fix it)

Either make golfer a property of app (and remove the Dim statement) or add a module & make golfer a property of that (and remove the dim statement).

Your problem is that golfer is a local property of App.Open so is not “in skope” elsewhere.

It doesn’t exist in those two methods because “golfer” is a local variable in the App.Open event. Either pass “golfer” to those two methods or make “golfer” a property that’s available to those two methods and the App.Open event.

Thanks, Not sure how to do that.

[quote=108216:@Tim Parnell]In your definition of golfer, RealSQLDatabase should be SQLiteDatabase
(I think that should fix it)[/quote]

Didn’t fix it, thanks.

[quote=108220:@Wayne Golding]Either make golfer a property of app (and remove the Dim statement) or add a module & make golfer a property of that (and remove the dim statement).

Your problem is that golfer is a local property of App.Open so is not “in skope” elsewhere.[/quote]

Not sure how to do that, thanks.

Got it, many thanks for the help. Shane

Sorry, re-read your post, and now I see the problem. The other two are certainly correct.