Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

byref argument type mismatch (code behind form) 1

Status
Not open for further replies.

simon551

IS-IT--Management
May 4, 2005
249
Hi,
I get an error message "byref argument type mismatch" in this bit of code developed by a former co-worker. On background, I copied this code from another form and am trying to update it for use with the current form. All I've done is copy this bit of code and change the name of the reference subform. It calls a function that is in a module called cResizer, and is used to resize controls on the form, for better reading to the user. It gets stuck on this part: fsubTimesheetReviewMode_Dets in the Form_Open event. Thanks in advance for your help.

Code:

Dim fsubTimesheetReviewMode_DetsResize As cResizer

Private Sub Form_Close()

Set fsubTimesheetReviewMode_DetsResize = Nothing
DoCmd.Close acForm, "frmTimesheetDets_edit"
End Sub

Private Sub Form_Open(Cancel As Integer)
Set fsubTimesheetReviewMode_DetsResize = New cResizer
fsubTimesheetReviewMode_DetsResize.Init Me, fsubTimesheetReviewMode_Dets, xHeight
txtTSDate.SetFocus
End Sub

Private Sub Form_Resize()
If Not fsubTimesheetReviewMode_DetsResize Is Nothing Then fsubTimesheetReviewMode_DetsResize.Resize
End Sub
 
Did you include the class module that this code seems to need when you copied?
 
Hi. The module is in the database. On the form I copied this bit of code, it seems to work fine. Here is the code on that form (in the same db):

Dim subformERDE_DetsResize As cResizer

Private Sub Form_Close()
Set subformERDE_DetsResize = Nothing
End Sub

Private Sub Form_Open(Cancel As Integer)
Set subformERDE_DetsResize = New cResizer
subformERDE_DetsResize.Init Me, subformERDE_Dets, xHeight
End Sub

Private Sub Form_Resize()
If Not subformERDE_DetsResize Is Nothing Then subformERDE_DetsResize.Resize
End Sub

 
Search for cResizer, or look in the Project window for class modules. I think you will find that there is a class module, as well as the module that the above code appears in.
 
Yes, there is a module called cResizer that this code references. It is in the database.
 
You need to import the full module. It is not an ordinary module, it is a Class Module. :)
 
Not sure how to do that. Import to the form code?
 
Sorry, my mind is wandering. [blush] Can we start again?
It seems that it does not like fsubTimesheetReviewMode_DetsResize. The message "byref argument type mismatch" means that it expects fsubTimesheetReviewMode_DetsResize to be some specific object. For example, if a module has:

Function TryThis(frmTry As Form)

It will give the error you got if frmTry is not a form.
 
Thanks Remou. I found the problem. I misunderstood the code. The form I copied from had a subform with an "_Dets" at the end and I mistakenly thought that it was part of the code (rather than part of the subform name.) Thanks for helping me and spelling out the problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top