msiudut
msiudut

Reputation: 251

MS Access crashes every time I try to open Visual Basic

So I have a split db.

dbBackEnd: Lives on the network drive, users don't touch it except through the front ends.
dbFrontEndv1:Stored by me for safekeeping, works fine
dbFrontEndv2:Stored by me for safekeeping, works fine
dbFrontEndv3:Users are interacting with this now, works fine
dbFrontEndv4: Freezes every time I try to do something in VBA

The game I've played a half a dozen times now is this.

(1) Copy dbFrontEndv3 to a new folder and rename it dbFrontEndv4.

(2) Open dbFrontEndv4 and open Form1. If I save now and re-enter it works fine.

(3) Add 1 or 2 command buttons. Command buttons triggering macros work fine. The VBA ones are the ones causing trouble here.

(4) Compile, no errors.

(4) Save and exit

(5) Open dbFrontEndv4, click the form or anything else relating to VBA.

(6) Errors: "Microsoft Access is not responding...", "Acces is restarting.

After adding and subtracting subs, saving, closing and reopening, this seems to be the offending one.

Private Sub cmdMCF_Click()
Dim appExcel As Excel.Application
Dim wbook As Excel.Workbook
Dim wsheet As Excel.Worksheet

Set appExcel = New Excel.Application
appExcel.Visible = True
Set wbook = appExcel.Workbooks.Open("C:\Path\MyDoc.xlsx")
Set wsheet = wbook.Worksheets("MCF")

With wsheet
    .Cells(10, 1).Value = txtCustomerName
    .Cells(10, 2).Value = txtCustomerNumber
    .Cells(10, 3).Value = txtAddress + " " + txtCity + " " + txtState + " " + txtzip

    .Cells(12, 1).Value = txtPhone
    .Cells(12, 2).Value = txtEmail
    .Cells(12, 3).Value = txtmeasurenumber

    .Cells(14, 1).Value = txtStore
    .Cells(14, 2).Value = txtAssignedIP

End With

End Sub

It is fine if it is just sitting int he code. But the moment I title a button cmdMCF, the errors start.

The thing is this sub, "Copy and Past", is in use right now on dbFrontEndv3. With little difficulty, I had the same error once when implementing dbFrontEndv3. But then it worked fine.

What in the code above could be causing these random crashes?

Upvotes: 1

Views: 1338

Answers (1)

jhTuppeny
jhTuppeny

Reputation: 970

I've had similar issues where a form was created in one version of access and then edited in a different version. Although the files should be compatible across versions there are some differences.

Try recreating the form from scratch in the version that you're using.

Upvotes: 1

Related Questions