set dbs = another database?

W

Wez.k

How do I "set dbs = " to something other than CurrentDB?

I am creating a new database from Vb and I want to set the startup
properties as the database is crearted so that a form opens when the database
starts. I've found out how to do that in the current database, but I cant
make it work for the newly created database. Code from online help is as
follows:

Sub SetStartupProperties()
Const DB_Text As Long = 10
Const DB_Boolean As Long = 1
ChangeProperty "StartupForm", DB_Text, "SYM grp inst request form"
ChangeProperty "StartupShowDBWindow", DB_Boolean, False
ChangeProperty "StartupShowStatusBar", DB_Boolean, False
ChangeProperty "AllowBuiltinToolbars", DB_Boolean, False
ChangeProperty "AllowFullMenus", DB_Boolean, False
ChangeProperty "AllowBreakIntoCode", DB_Boolean, True
ChangeProperty "AllowSpecialKeys", DB_Boolean, False
ChangeProperty "AllowBypassKey", DB_Boolean, False
End Sub
*******************
Function ChangeProperty(strPropName As String, varPropType As Variant,
varPropValue As Variant) As Integer

Dim dbs As Object, prp As Variant
Const conPropNotFoundError = 3270

**** Set dbs = CurrentDB (I would like this to be my new database) ****

On Error GoTo Change_Err
dbs.Properties(strPropName) = varPropValue
ChangeProperty = True

Change_Bye:
Exit Function

Change_Err:
If Err = conPropNotFoundError Then ' Property not found.
Set prp = dbs.CreateProperty(strPropName, _
varPropType, varPropValue)
dbs.Properties.append prp
Resume Next
Else
' Unknown error.
ChangeProperty = False
Resume Change_Bye
End If
End Function

Thanks
 
M

Marshall Barton

Wez.k said:
How do I "set dbs = " to something other than CurrentDB?

I am creating a new database from Vb and I want to set the startup
properties as the database is crearted so that a form opens when the database
starts. I've found out how to do that in the current database, but I cant
make it work for the newly created database. Code from online help is as
follows:

Sub SetStartupProperties()
Const DB_Text As Long = 10
Const DB_Boolean As Long = 1
ChangeProperty "StartupForm", DB_Text, "SYM grp inst request form"
ChangeProperty "StartupShowDBWindow", DB_Boolean, False
ChangeProperty "StartupShowStatusBar", DB_Boolean, False
ChangeProperty "AllowBuiltinToolbars", DB_Boolean, False
ChangeProperty "AllowFullMenus", DB_Boolean, False
ChangeProperty "AllowBreakIntoCode", DB_Boolean, True
ChangeProperty "AllowSpecialKeys", DB_Boolean, False
ChangeProperty "AllowBypassKey", DB_Boolean, False
End Sub
*******************
Function ChangeProperty(strPropName As String, varPropType As Variant,
varPropValue As Variant) As Integer

Dim dbs As Object, prp As Variant
Const conPropNotFoundError = 3270

**** Set dbs = CurrentDB (I would like this to be my new database) ****
[snip]

Use the OpenDatabase method to open an existing mdb file.

If the database file does not yet exist, then use the
CreateDatabase method.
 
G

George Nicholson

If dbs is Nothing then:
Use the OpenDatabase method to open an existing mdb file.

If the database file does not yet exist, then use the
CreateDatabase method.

Otherwise, leave dbs unchanged (you've already opened or created it once. No
need to keep doing it).

--
George Nicholson

Remove 'Junk' from return address.


Marshall Barton said:
Wez.k said:
How do I "set dbs = " to something other than CurrentDB?

I am creating a new database from Vb and I want to set the startup
properties as the database is crearted so that a form opens when the
database
starts. I've found out how to do that in the current database, but I cant
make it work for the newly created database. Code from online help is as
follows:

Sub SetStartupProperties()
Const DB_Text As Long = 10
Const DB_Boolean As Long = 1
ChangeProperty "StartupForm", DB_Text, "SYM grp inst request form"
ChangeProperty "StartupShowDBWindow", DB_Boolean, False
ChangeProperty "StartupShowStatusBar", DB_Boolean, False
ChangeProperty "AllowBuiltinToolbars", DB_Boolean, False
ChangeProperty "AllowFullMenus", DB_Boolean, False
ChangeProperty "AllowBreakIntoCode", DB_Boolean, True
ChangeProperty "AllowSpecialKeys", DB_Boolean, False
ChangeProperty "AllowBypassKey", DB_Boolean, False
End Sub
*******************
Function ChangeProperty(strPropName As String, varPropType As Variant,
varPropValue As Variant) As Integer

Dim dbs As Object, prp As Variant
Const conPropNotFoundError = 3270

**** Set dbs = CurrentDB (I would like this to be my new database)
****
[snip]

Use the OpenDatabase method to open an existing mdb file.

If the database file does not yet exist, then use the
CreateDatabase method.
 
W

Wez.k

Sorry folks, I didn't explain myself properly.

I have created the file successfully. Now what I want to do is set its
startup properties in Vb. I want a certain form to open on startup, minimal
menu's, no special keys etc. The code I supplied comes from the Help files,
but it only sets the properties of the Current database, ie the one I'm
working from, and I dont know how to adapt it to set the properties of the
new database instead.

Wes.

George Nicholson said:
If dbs is Nothing then:
Use the OpenDatabase method to open an existing mdb file.

If the database file does not yet exist, then use the
CreateDatabase method.

Otherwise, leave dbs unchanged (you've already opened or created it once. No
need to keep doing it).

--
George Nicholson

Remove 'Junk' from return address.


Marshall Barton said:
Wez.k said:
How do I "set dbs = " to something other than CurrentDB?

I am creating a new database from Vb and I want to set the startup
properties as the database is crearted so that a form opens when the
database
starts. I've found out how to do that in the current database, but I cant
make it work for the newly created database. Code from online help is as
follows:

Sub SetStartupProperties()
Const DB_Text As Long = 10
Const DB_Boolean As Long = 1
ChangeProperty "StartupForm", DB_Text, "SYM grp inst request form"
ChangeProperty "StartupShowDBWindow", DB_Boolean, False
ChangeProperty "StartupShowStatusBar", DB_Boolean, False
ChangeProperty "AllowBuiltinToolbars", DB_Boolean, False
ChangeProperty "AllowFullMenus", DB_Boolean, False
ChangeProperty "AllowBreakIntoCode", DB_Boolean, True
ChangeProperty "AllowSpecialKeys", DB_Boolean, False
ChangeProperty "AllowBypassKey", DB_Boolean, False
End Sub
*******************
Function ChangeProperty(strPropName As String, varPropType As Variant,
varPropValue As Variant) As Integer

Dim dbs As Object, prp As Variant
Const conPropNotFoundError = 3270

**** Set dbs = CurrentDB (I would like this to be my new database)
****
[snip]

Use the OpenDatabase method to open an existing mdb file.

If the database file does not yet exist, then use the
CreateDatabase method.
 
M

Marshall Barton

I guess I didn't explain it either.

The OpenDatabase method returns the database object that was
opened.

Set dbs = OpenDatabase(path)

then use that database object to set the properties. If you
already have the dbs opened for some other reason, you
should pass dbs to the procedure instead of reopening it.
--
Marsh
MVP [MS Access]


Wez.k said:
Sorry folks, I didn't explain myself properly.

I have created the file successfully. Now what I want to do is set its
startup properties in Vb. I want a certain form to open on startup, minimal
menu's, no special keys etc. The code I supplied comes from the Help files,
but it only sets the properties of the Current database, ie the one I'm
working from, and I dont know how to adapt it to set the properties of the
new database instead.

Wez.k wrote:
How do I "set dbs = " to something other than CurrentDB?

I am creating a new database from Vb and I want to set the startup
properties as the database is crearted so that a form opens when the
database
starts. I've found out how to do that in the current database, but I cant
make it work for the newly created database. Code from online help is as
follows:

Sub SetStartupProperties()
Const DB_Text As Long = 10
Const DB_Boolean As Long = 1
ChangeProperty "StartupForm", DB_Text, "SYM grp inst request form"
ChangeProperty "StartupShowDBWindow", DB_Boolean, False
ChangeProperty "StartupShowStatusBar", DB_Boolean, False
ChangeProperty "AllowBuiltinToolbars", DB_Boolean, False
ChangeProperty "AllowFullMenus", DB_Boolean, False
ChangeProperty "AllowBreakIntoCode", DB_Boolean, True
ChangeProperty "AllowSpecialKeys", DB_Boolean, False
ChangeProperty "AllowBypassKey", DB_Boolean, False
End Sub
*******************
Function ChangeProperty(strPropName As String, varPropType As Variant,
varPropValue As Variant) As Integer

Dim dbs As Object, prp As Variant
Const conPropNotFoundError = 3270

**** Set dbs = CurrentDB (I would like this to be my new database)
****
[snip]
"Marshall Barton" wrote
Use the OpenDatabase method to open an existing mdb file.

If the database file does not yet exist, then use the
CreateDatabase method.
 
W

Wez.k

Ah, now I understand...

Thanks Marshall

Marshall Barton said:
I guess I didn't explain it either.

The OpenDatabase method returns the database object that was
opened.

Set dbs = OpenDatabase(path)

then use that database object to set the properties. If you
already have the dbs opened for some other reason, you
should pass dbs to the procedure instead of reopening it.
--
Marsh
MVP [MS Access]


Wez.k said:
Sorry folks, I didn't explain myself properly.

I have created the file successfully. Now what I want to do is set its
startup properties in Vb. I want a certain form to open on startup, minimal
menu's, no special keys etc. The code I supplied comes from the Help files,
but it only sets the properties of the Current database, ie the one I'm
working from, and I dont know how to adapt it to set the properties of the
new database instead.

Wez.k wrote:
How do I "set dbs = " to something other than CurrentDB?

I am creating a new database from Vb and I want to set the startup
properties as the database is crearted so that a form opens when the
database
starts. I've found out how to do that in the current database, but I cant
make it work for the newly created database. Code from online help is as
follows:

Sub SetStartupProperties()
Const DB_Text As Long = 10
Const DB_Boolean As Long = 1
ChangeProperty "StartupForm", DB_Text, "SYM grp inst request form"
ChangeProperty "StartupShowDBWindow", DB_Boolean, False
ChangeProperty "StartupShowStatusBar", DB_Boolean, False
ChangeProperty "AllowBuiltinToolbars", DB_Boolean, False
ChangeProperty "AllowFullMenus", DB_Boolean, False
ChangeProperty "AllowBreakIntoCode", DB_Boolean, True
ChangeProperty "AllowSpecialKeys", DB_Boolean, False
ChangeProperty "AllowBypassKey", DB_Boolean, False
End Sub
*******************
Function ChangeProperty(strPropName As String, varPropType As Variant,
varPropValue As Variant) As Integer

Dim dbs As Object, prp As Variant
Const conPropNotFoundError = 3270

**** Set dbs = CurrentDB (I would like this to be my new database)
****
[snip]

Use the OpenDatabase method to open an existing mdb file.

If the database file does not yet exist, then use the
CreateDatabase method.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top