2003 - 2007 VBA issue

S

stockwell43

Hello,

I have a simple database that was created in 2003. I copied it and brought
it home to try it on 2007. I heard, it should still work as the coding is the
same but maybe some of the mechanics in 2007 maybe different. I open the
database and the main menu popped up. When I clicked on the CBO for the
forms, nothing happened. When I clicked on the CBO for the reports, nothing
happened. When I clicked on the exit button, nothing happened. I then opened
the database in design view and clicked on the tables, forms, reports and
queries and they all opened fine. I am guessing it has something to do with
the code behind the main menu. This was from another database so I am not
sure what could be wrong. Here it is:

Option Compare Database
Option Explicit ' All variables must be declared

Private blnShowReport As Boolean

Private Sub Form_Activate()
ClearComboboxes
DoCmd.Restore
End Sub

Private Sub Form_Load()
'Call ReportPermissions
'Call FillComboList(cmbReport)
'Call FillForm(cmbForm)
ClearComboboxes
ShortcutMenuBar = "DBSecurity"
Call basDatabaseSecurity.PreventBypassNewProp
End Sub


Private Sub Form_Current()
ClearComboboxes
End Sub


Private Sub cmdExit_Click()
DoCmd.Quit
End Sub


Private Sub cmbForm_Change()
On Error GoTo eh
Dim FileName As String

FileName = DLookup("[TaskFileName]", "tblFormName", "[TaskFormName] =
cmbForm.Value")
DoCmd.OpenForm FileName, acNormal

'Dim strFormName As String
'strFormName = cmbForm.ItemData(cmbForm.ListIndex)
' Open reports with current filter
'DoCmd.OpenForm strFileName, acNormal

Exit Sub

eh:
If Err.Number <> 2501 Then
MsgBox Err.Number & " " & Err.Description, vbInformation,
"Form-Related Error"
Else
cmbForm = ""
End If

End Sub

Private Sub cmbReport_Change()
On Error GoTo eh
Dim ReportName As String

ReportName = DLookup("[ReportFileName]", "tblReportName",
"[ReportFormName] = cmbReport.Value")
DoCmd.OpenReport ReportName, acViewPreview, , Me.Filter

'strReportName = cmbReport.ItemData(cmbReport.ListIndex)
' Open reports with current filter
'DoCmd.OpenReport strReportName, acViewPreview, , Me.Filter

Exit Sub

eh:
If Err.Number <> 2501 Then
MsgBox Err.Number & " " & Err.Description, vbInformation,
"Report-Related Error"
Else
cmbReport = ""
End If
End Sub

Private Sub ClearComboboxes()
cmbReport = ""
cmbForm = ""
End Sub

Private Sub Command19_Click()
On Error GoTo Err_Command19_Click

Dim oApp As Object

Set oApp = CreateObject("Word.Application")
oApp.Visible = True

Exit_Command19_Click:
Exit Sub

Err_Command19_Click:
MsgBox Err.Description
Resume Exit_Command19_Click

End Sub


Any help would be greatly appreciated as I am in big trouble if I have to
redo all the database if we convert to 2007 which is a good possibility from
what I heard.

Thanks!!!!
 
G

ghetto_banjo

I had this problem at first, but it had nothing to do with the
programming of the buttons. Access 2007 has more security and it
turned off all macros and whatnot. Make sure all of that is enabled,
and also you can specify that the database is from a trusted location.
 
S

stockwell43

Hi, Thank you for replying.

Could you please tell me how I do this in 2007? I just loaded it about a
week ago and haven't had time to playaround with it to figure anything out.

Also, do you know how to add toolbars rather than loading everything into
the quick toolbar?

Thank you!!!
 
S

stockwell43

Thank you for the article.

In reading, it seems like it disables macros but there are none in the
database. Also, the last paragraph says it is for programmers so no one can
get to the back of the database but I was too so I don't think that was
enabled.

The Main Menu is quite simple with only two CBO and two buttons and when I
opened the database, nothing worked on the main menu. I did not try to input
any data into the form.

Do you have any other suggestions as to what it might be? I will save the
link because it is a good piece of information and I can pass it on to others.

Thanks!!!!
 
P

Paul Shapiro

Access 2007 security defaults to disabling all code except trusted code.
Code is trusted if the db is signed with a trusted digital signature, or if
the db is located in a trusted location. The trusted location is the easiest
to control. Click the Office button in the top left corner of the Access
window. At the bottom of the dialog click Access Options. Choose Trust
Center in the left window pane. Click Trust Center Settings in the right
pane. In the new dialog choose Trusted Locations in the left pane. Click the
Add New Location button at the bottom right and add the folder containing
your db. You can optionally choose to trust all subfolders of that location.
If your db is on a network share, check the box to 'Allow Trusted Locations
on My Network (not recommended)'.

That probably takes care of the problem. If not, open the VBA editor and
check the references (Tools->References). If any selected references are
marked as MISSING you need to resolve that or no code runs.
 
S

stockwell43

Hi Paul,

It worked fine. I guess it was the same thing Ghetto Banjo was saying I just
wasn't understanding it I guess. You guys were a big help. Many Thanks!!!!!!!
 

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