Linking vba modules in MS Access 2007
I am upgrading a database system from Access 2000 db to Access 2007, which communicates with several chemistry measuring devices(pH meter, scale, etc) via an RS 232 serial port. The first db consists of several modules containing vba code that enables the communications with the ports, as well as supports the code behind the forms in the second db. The user, or lab tech, navigates through the fo开发者_开发问答rms in the second db to interact with the lab devices, and also to generate the reports which display the info. from the devices. The reports are also part of the second db. The code works in Access 2000, but once I convert it to 2007, the code in the second db cannot find the function calls in the first db that dictate the progression from screen to screen. I have tried importing the modules into the second db, and I have tried linking them, but it still doesn't work. The error message is #438: "Object doesn't support this property or method." Any suggestions would be greatly appreciated.
Here is the code for the first function that is not being called correctly:
Description:
' This routine is used to return to the calling form and close the active form.
'
' Input:
' strFormCalled --- the active form
' strCallingForm --- the form that called the active form
' blnUnhideOrOpen --- whether to open or just unhide form
Public Sub basReturnToCallingForm(ByVal strFormCalled As String, ByVal _
strCallingForm As Variant, Optional blnUnhideOrOpen As Boolean = True)
On Error GoTo err_basReturnToCaliingForm
If Not basIsBlankString(strCallingForm) And blnUnhideOrOpen Then
DoCmd.OpenForm strCallingForm, acNormal
Else
Call basUnHideForm(strCallingForm)
End If
Call basCloseForm(strFormCalled)
exit_basReturnToCaliingForm:
Exit Sub
err_basReturnToCaliingForm:
Err.Raise Err.Number, "basReturnToCaliingForm", Err.Description
End Sub
I will post the second function shortly, but I have to go to a meeting... The second function that isn't 'working' is a cmdStartClick that is supposed to be called when a user initializes a pump. However, within that function, it's also sticking on a line that is supposed to progress to the next form in the db. The other thing is that the code works in Access 2002, but not in Access 2007...
Here is the second section of code that the program continuously chokes on:
Private Sub cmdClose_Click()
On Error GoTo err_cmdCloseClick
Call basReturnToCallingForm(Me.Name, m_strCallingForm, False)
exit_cmdCloseClick:
Exit Sub
err_cmdCloseClick:
MsgBox basGetString(g_clngUnexpectedError, Err.Number, "cmdCloseClick", _
Err.Description), vbCritical, "Unexpected Error"
Resume exit_cmdCloseClick
End Sub
I have checked the references, and as far as I can tell, everything is included that needs to be. Since I last posted, we have been able to get the program working in Access 2002, but we still haven't had any luck with Access 2007...
update 6/14/10:
So... in the design view of the form that functions as the gui for interacting with an electronic pump (to dispense chemicals in a chem. lab), there is supposed to be an ActiveX object embedded. It's missing. However, when I try to reinsert it, I receive the message: "The OLE server isn't registered. To register the OLE server, reinstall it." However, I've reinstalled the updated drivers for the RS232 ports, and I still get the same message. In short, Access won't let me insert the ActiveX control the form needs. So this is where I'm at as of 8:30 EST on Monday morning. If anyone has a suggestion,... I'm ready to be finished with this project!
It turns out I had to register the ActiveX control that I needed, which is done a bit differenly in Access 2007. Here's the link, if anybody is interested. I used method 2. Thanks for the helpful comments. http://support.microsoft.com/kb/918574
In VBA Code Editor check Tools->References and see if any are marked as MISSING.
精彩评论