method or data member not found visual basic как исправить
Method or data member not found visual basic как исправить
This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.
Asked by:
Question
Hello I’m getting the error message «Method or data member not found». This happens with a form that I’m working on in Access. The form is used to search the database for records matching a name that is entered into a text box. Here is the code in VBA if it is any help:
Option Compare Database
Private Sub RefreshSearch()
Me.chkDoSearch.Value = True
Me.FarmerSearchbyName_subform.Requery
Me.FarmerSearchbyName_subform.SetFocus
End Sub
Private Sub btnNewSearch_Click()
With Me.txtLookup
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
End With
End Sub
Private Sub btnOk_Click()
If Me.FarmerSearchbyName_subform.CurrentRecord > 0 Then
All replies
Try adding referenc to the Subfors Form as :
Me.FarmerSearchbyName_subform.Form.CurrentRecord
Well, in earlier versions of Access (2003 and earlier) the subform’s FORM object itself could wind up being NULL if the query from the parent form’s data resulted in NO valid records.
In that circumstance, referencing to subform’s properties and objects could result in 438 errors and «method or data member not found» sorts of errors. Is it possible that in your situation you are getting into data results where the subform could contain no data?
I generally code those lines more defensively to detect and adjust to the «no data / no valid subform FORM object» cases without throwing those types of error messages.
Private Sub btnOk_Click()
dim oFM as form_mySubFormNameHere
set ofm = Me.FarmerSearchbyName_subform.form
if not ofm is nothing then
If ofm.CurrentRecord > 0 Then
I now get an empty page. What could cause this? There is no error message
duplicate the query for the subform in the query designer an manually input the data values from the parent form (as filters in the query).
I will usually hide the subform control in the » ‘else react accordingly» code area and display some sort of warning text (a label control, usually hidden behind the nornally displayed subform control) about having no data to display (and perhaps showing a control button to add data as required/permitted by the business rules for the system).
I often put this type of code in the form_current event for the parent form to toggle the display of the appropriate controls depending upon whether the subform has data to display/edit or not.
Method or data member not found compile issue
I have a VB6 project that I didn’t create but I have to update, when I go to make the exe I get a compile error: Method or data member not found, and it points too «SCom1.FileReceive» in the code below. When I look at the Main form, the SCom1 control is a PictureBox.
This code has been working for the last 5 years but I don’t know why SCom1 is a picturebox, or why I’m getting the error, is it a reference? SCom1 to me looks like a MSComm function? Let me know if anyone has any ideas, I just don’t know VB enough to know how to troubleshoot this. Thanks
1 Answer 1
The machine which you have opened the code doesn’t have the mscomm32.ocx file or the ocx file not registered properly.
When vb cannot reference an ocx, it’ll convert the relevant control to a picture box control.
What you have to do is, close the project without saving. Then open system32 folder and check for mscomm32.ocx file. If the file is not there then you have to download that from the intenet. The register the file using regsvr32 command in command prompt.
After this you can open the vb6 project and start working.
EDIT : Included the update in the comments to the answer, this will help other users in the future. 🙂
So check on the working machine or in project folder whether there are any ocx file exists in the relevant name (in this case SCom.ocx ).
if there is a file exists in such name, register that file using regsvr32 (if not registered), then add that to toolbox, then replace the picture box control with the relevant control (make sure the name tally).