Method or Data Member not found?

S

Sharon

When I run the code below it gives me the error that Method or Data Member
not found. I have compared the "frmExpenseReport" and they appear to be the
same as the "frmPurchaseOrder" as far as properties, etc. I added the
stDocName = "frmPurchaseOrder" because when the drop down opens the name
PurchaseOrderID doesn't show, but the PurchaseOrderID_Label does? Why?
How do I fix this? What I am trying to do is that when the button is
clicked, depending on the value selected in another combo box, I want it to
open either one form (frmExpenseReport) or another (frmPurchaseOrder).
Thanks for any help.

Private Sub VIEW_REPORT_Click()
On Error GoTo Err_VIEW_EXPENSE_REPORT_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmExpenseReport"
stDocName = "frmPurchaseOrder"

If Me!cmbMethodofPayment = 1 Then
DoCmd.OpenForm "frmExpenseReport", , , "ExpenseReportID = " &
Me.ExpenseReportID

ElseIf Me!cmbMethodofPayment = 2 Then
DoCmd.OpenForm "frmExpenseReport", , , "ExpenseReportID = " &
Me.ExpenseReportID

ElseIf Me!cmbMethodofPayment = 3 Then
DoCmd.OpenForm "frmExpenseReport", , , "ExpenseReportID = " &
Me.ExpenseReportID

ElseIf Me!cmbMethodofPayment = 4 Then
DoCmd.OpenForm "frmPurchaseOrder", , , "PurchaseOrderID = " &
Me.PurchaseOrderID

End If



-
S
 
C

Chaim

Sharon,

Since you set stDocName in two consecutive statements, the value is just the
last value assigned. Where is stDocName being used? It shows up no place in
this piece of code. This is clearly not the entire event procedure.

Have you run this with the debugger so that you know which Method or Data
Member it is specifically complaining about?

Maybe you should post all of the procedure and tell us what method or data
member it is complaining about. Also, how do you have your combo box
(cmbMethodofPayment) set up? How many columns? Which is the bound column?
What does its data source look like?

Good Luck!
 
J

Jwy

I am experiencing the same problem. I have a table field named RecordID
which is not used on a form. When I try to use code:

If Me.ProjectStatus = "Completed" Then
Me.RecordID = "PZ"
End If

I get the error message "Method or Data Member not found" for RecordID.

I can't see the field RecordID in the drop down box when entering the code,
yet it is in the table.

Why is this happening?

All help is appreciated.
 
B

Brendan Reynolds

Is the field included in the SELECT clause? A field could be included in a
WHERE clause, or an ORDER BY clause, without being included in the SELECT
clause, in which case it would not be available as a property of the form.
In the first two examples below, the field 'RecordID' will not be available,
only the third example will make this field available as a property of the
form ...

SELECT FieldOne, FieldTwo FROM SomeTable WHERE RecordID = Whatever

SELECT FieldOne, FieldTwo FROM SomeTable ORDER BY RecordID

SELECT FieldONe, FieldTwo, RecordID FROM SomeTable

Another possibility is that the field might be aliased ...

SELECT Format([RecordID], "00000") AS Whatever FROM SomeTable

In this example, you could not refer to the field as 'RecordID'. You could
read it using the alias ('Whatever' in the example above) but to write to it
you'd need to add an additional reference to the actual field to the query
....

SELECT RecordID, Format([RecordID], "00000") AS Whatever FROM SomeTable

If this doesn't enable you to resolve the problem, try posting the SQL for
the query, I'm sure someone will be able to see what the problem is.
 
M

MacDermott

In some such situations, I've resorted to creating a textbox for RecordID,
and setting its visible property to False.
 
J

Jwy

Thanks, this idea worked. Strange, though, I had another field in the table
that I was using to test with and I had no problem what so ever. This test
field was not even in the query and it updated just fine.

Thanks for your help!
 

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