I have a problem with the following code

G

Glenn Brown

I have a problem with the following code. When I run the data and application
databases on my local PC, everything works fine. Then I put the data file on
a network share the code breaks (doesn't work)?

This is how the code works;
1. While in form A, the user double clicks on the company field to create a
new company.
2. A form opens (frmCompaniesNew), the user adds info and then clicks the ok
button. This company should be added into the company field on form A. This
is the part that doesn't work?

Why...could someone please help?

CODE FOR FORM A
Private Sub txtCompanyID_DblClick(Cancel As Integer)
On Error GoTo Err_txtCompanyID_DblClick
DoCmd.OpenForm "frmCompaniesNew", , , , , acDialog, "GotoNew"
Me.txtCompanyID.Requery
Me.txtCompanyID = Forms!frmCompaniesNew.txtCompanyID
DoCmd.Close acForm, "frmCompaniesNew"
Exit_txtCompanyID_DblClick:
Exit Sub
Err_txtCompanyID_DblClick:
Resume Exit_txtCompanyID_DblClick
End Sub

CODE FOR OK BUTTON IN "frmCompaniesNew" FORM
Private Sub cmdOk_Click()
On Error GoTo Err_cmdOk_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Me.Visible = False
Exit_cmdOk_Click:
Exit Sub
Err_cmdOk_Click:
Resume Exit_cmdOk_Click
End Sub
 
J

Jeff Boyce

Glenn

When you say "doesn't work" do you mean it fails silently, or does it
provide an error message of some kind?

Just a hunch, but that first block of code looks like your second form has
already been closed when you try to set the value of your company name in
the textbox on your first form...

Is there a reason you aren't using a combo box for the company name?
There's a NotInList event that fires for the combo box, if you have set
LimitToList. You can use that to add a new item...
 

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