The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
|
|
Object does not support this property or method
Posted: 13 Nov 07 11:33 AM
|
I receive this error when working on a new cdmAddressClick method. The error occurs at the **. I suppose there is a good chance that my If statement that references Count could not be functioning properly as well.
Sub cmdAddressClick(Sender) Dim strSQL, strDesc, strAddrID Dim blnEnabled Dim objRS Dim i
' PopupMenu.Items.clear blnEnabled = Application.BasicFunctions.GetMenuSecurity(70) Set objRS = objSLXDB.GetNewRecordset strSQL = "Select COUNT(*) AS Addresses From ADDRESS Where ENTITYID = '" & EntityID & "' " objRS.Open strSQL, objSLXDB.COnnection If objRS.Fields("Addresses").Value < 11 Then objRS.Close
strSQL = "Select A1.DESCRIPTION, A1.ADDRESSID From ADDRESS A1 " & _ "where ENTITYID = '" & EntityID & "' ORDER BY DESCRIPTION"
objRS.Open strSQL, objSLXDB.Connection i = 0 Do While Not objRS.EOF strDesc = objRS.Fields("DESCRIPTION").Value strAddrID = objRS.Fields("ADDRESSID").Value If Not IsNull(strDesc) Then PopupMenu.Items.Add PopupMenu.Items.Items(i).Caption = "" & objRS.Fields("DESCRIPTION").Value PopupMenu.Items.Items(i).Tag = "" & objRS.Fields("ADDRESSID").Value If CrntAddress = strAddrID Or Not blnEnabled Then PopupMenu.Items(i).Enabled = False End If i = i + 1 End If objRS.MoveNext Loop
** PopupMenu.Items.Add PopupMenu.Items.Items(i).Caption = "-" PopupMenu.Items.Add PopupMenu.Items.Items(i + 1).Caption = Application.Translator.Localize("Add/Edit...") PopupMenu.Items.Items(i + 1).Enabled = Application.BasicFunctions.GetMenuSecurity(70)
objRS2.Close Set objRS = Nothing
PopupMenu.Popup Else MsgBox Application.Translator.Localize("This account contains too many addresses to display."),vbOKOnly,"Attention!" End If End Sub |
|
|
|
Re: Object does not support this property or method
Posted: 13 Nov 07 1:52 PM
|
I have changed my approach, but my If statement is not working correctly. I do not know if I have utilized COUNT(*) properly. Any thoughts?
Sub cmdAddressClick(Sender) Dim strSQL Dim blnEnabled Dim objRS
blnEnabled = Application.BasicFunctions.GetMenuSecurity(70) Set objRS = objSLXDB.GetNewRecordset strSQL = "Select COUNT(*)As Addresses From ADDRESS Where ENTITYID = '" & EntityID & "' " objRS.Open strSQL, objSLXDB.Connection If objRS.Fields("Addresses").Value < 9 Then If mnuAddress.Items.Count = 0 Then BuildAddressPopupMenu mnuAddress, txtAccountID.Text, lblCurrentAddress.Caption Else mnuAddress.Popup End If Else MsgBox Application.Translator.Localize("This account contains too many addresses to display."),vbOKOnly,"Attention!" End If
objRS.Close Set objRS = Nothing
End Sub |
|
|
| |
|
Re: Object does not support this property or method
Posted: 14 Nov 07 2:42 PM
|
Looking at the code it looks as if the SQL statement is malformed. There is no space between COUNT(*) and the AS keyword. I would also assume that EntityID has a valid Account/Contact ID in it. If not then it would not find any of the addresses.
I do not think this matters but I would probably CINT the field retrieval
dim count count = cint(objRs.Fields("Addresses").Value) if count < 9 then ... else ... end if
what is the overarching logic here -> get the number of addresses if there is less then 9 addresses associated with the entity and there are no sub menu items then add a menu .. From your text it looks as if you are trying to add a menu item for every address associated for the selected entity is this correct?
Mark |
|
|
|
Re: Object does not support this property or method
Posted: 16 Nov 07 7:48 AM
|
A build address function is called from the Account and Contact screen. This function looks for all addressid's associated with an entity. When the entity is a contact, it performs fine. However, when the entity is an account, there can be around 10,000 addressid's associated. When this happens, performance takes a downward spiral. The ironic thing about this specific to my company is that we do not need the functionality for large accounts, just a few small ones. I was hoping to alter the function for the account screen so that it only builds the address list if there are less than 9 addressid's. If you have any thoughts on this, or would like more information, let me know. |
|
|
|
Re: Object does not support this property or method
Posted: 16 Nov 07 7:56 AM
|
10,000 associated addresses to a single account. That seems so strange to me. If I may ask what kind of business would have this kind of data. Are they using a account bucket to store generic data in without creating an account/contact pair.
When I looked at the code I also noticed that there was no space between the count(*) and the AS keyword. It looks as well that you can get an instance of the MenuItem instead of using the indexed items() collection to do your settings on.
Mark |
|
|
|
Re: Object does not support this property or method
Posted: 16 Nov 07 8:56 AM
|
We would be considered a supplier, and we only deal with authorized distributors. Every time someone places an order with one of these distributors, their shipping addresses is then associated with that account. Large distributors = lots of business = lots of shipping addresses. |
|
|
| |
|
Re: Object does not support this property or method
Posted: 16 Nov 07 6:28 PM
|
Back to the original error:
- Make sure that your variable is not NULL. You know, concatenating to a NULL will yield a NULL string. And you can't execute that on SQL. Place a Message box that displays the SQL statement, copy it over to Query Analyzer (yes, you can do CTRL+C on a message box and will copy its content) and execute it.
Set objRS = objSLXDB.GetNewRecordset [I would add parenthesis at the end, since you are calling a function, not a Sub] Set objRS = objSLXDB.GetNewRecordset()
Also, make sure that objSLXDB properly set.
|
|
|
|
Re: Object does not support this property or method
Posted: 19 Nov 07 11:33 AM
|
Nice thoughts with displaying strSQL, unfortunately the end of the statement is no included. strSQL is limited to: Select * From ADDRESS Where ENTITYID = ''. This explains why the query returns zero, but how would I need to change my SQL statement so that the WHERE clause is included in its entirety?
|
|
|
|
Re: Object does not support this property or method
Posted: 19 Nov 07 1:46 PM
|
Your SQL Statement is set as follows:
strSQL = "Select COUNT(*) AS Addresses From ADDRESS Where ENTITYID = '" & EntityID & "' "
Question: Where are you populating the EntityID variable? I didn't see it in the sample code you provided, so I would at least suspect it is a global variable on the Script that you are working on. This is what you need to figure out. |
|
|
|
Re: Object does not support this property or method
Posted: 20 Nov 07 7:35 AM
|
I believe that would be the hold up, I was not paying close enough to realize that Account Details, where this script is running, is in the System family. I assumed it was in the Account family and then would have had the EntityID readily available. I will have to look to see how the original method, BuildAddressPopupMenu, has the EntityID passed to it. |
|
|
|