Method or data member not found

pape93

New Member
Joined
Feb 1, 2011
Messages
14
Hi all, I came across this error message while trying to run the following code. Can you help with this problem?

Compile error: Method or data member not found

PHP:
Sub getFieldCurrency(ObjectName As ComboBox, Rng As Range)
  Dim conn As ADODB.Connection
  Dim curInfo As ADODB.Recordset
  Dim strConn, supName As String
  strConn = "Provider = Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & ThisWorkbook.Path & "\eps.mdb"
  Set conn = New ADODB.Connection
  conn.Open strConn
  Set curInfo = New ADODB.Recordset
  curInfo.Open "SELECT * FROM cur_tab WHERE cur_cod = '" + LCase(Trim(ePrisoft.ObjectName.value)) + "'", _
        conn, adOpenDynamic, adLockOptimistic, adCmdText
  If (curInfo.BOF Or curInfo.EOF) Then
    'if no records found
  Else
    'else show record
    Rng.value = curInfo("cur_rat")
  End If
    curInfo.Close
    Set curInfo = Nothing
    conn.Close
    Set conn = Nothing
 
End Sub

The following line is highlighted after the error message is displayed:
ePrisoft.ObjectName.value

Any help will be deeply appreciated
thanks much.
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
What is ePrisoft?

Some sort of 3rd part application you are automating?
 
Upvote 0
Do you mean a userform?

Then perhaps ObjectName is just being used as a 'placeholder' and you need to put the actual name of the control of interest there.
 
Upvote 0
I was hoping it could be used that way. so I would just call it similar to a function like this:

getFieldCurrency cboBlCurr, Worksheets("BL").Range("D6")

cboBLCurr being the combobox name and then specifying the range. Can it be done this way?

thanks
 
Upvote 0
I just noticed that you were passing ObjectName as an argument/parameter.

You should be able to do that, but in the sub you wouldn't use the userform name since you are passing the combobox itself not just the name.

If you were passign the name, as a a string probably, you would need the userform name and you would also need to use it's Controls collection.
Rich (BB code):
Sub getFieldCurrency(strCombo Name As String, Rng As Range)
...
curInfo.Open "SELECT * FROM cur_tab WHERE cur_cod = '" + LCase(Trim(ePrisoft.Controls(strComboName).Value)) + "'", _
conn, adOpenDynamic, adLockOptimistic, adCmdText
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,828
Members
452,946
Latest member
JoseDavid

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top