![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
After splitting the database, portions of code that use recordsets (now based on linked tables) don't work. Runtime error 3251 "Operation is not supported for this type of object." I've read past posts on the same issue, but I can't get any solutions to work. Self- taught amateur (so be gentle and use itty-bitty words, please). Even hard-coding the new BE would be fine, really! My users are trying to place folks in jobs and feed widows -- AND their air conditioning just died! I really need to fix this quickly. This code creates the next unique Household_Id (based on adding 1 to the last value added). The line where it breaks is: Household_Id_Recordset.Index = "PrimaryKey" The location of the BE is: D:\Client Statistical Database \ClientDatabase_BE.mdb Option Compare Database Option Explicit Private current_db As Database Private Household_Id_Recordset As Recordset Private Household_Id_Table As TableDef Private Sub Form_Current() Dim Current_Household_Id_String As String Dim Current_Household_Id_Int As Long Dim Update_Sql As String 'Open Next_Household_Id table Set current_db = CurrentDb() Set Household_Id_Table = current_db.TableDefs("Next_Household_Id") Set Household_Id_Recordset = Household_Id_Table.OpenRecordset() Household_Id_Recordset.Index = "PrimaryKey" 'Find out next household id Current_Household_Id_String = Household_Id_Recordset.Fields(0).Value 'Pad left with zeros Current_Household_Id_String = Right("000000" & Current_Household_Id_String, 6) 'Write household id into the form Me![Household_Id] = Current_Household_Id_String 'Add 1 to next household id table Current_Household_Id_Int = Val(Current_Household_Id_String) Current_Household_Id_Int = Current_Household_Id_Int + 1 Update_Sql = "UPDATE Next_Household_Id SET Next_Household_Id.Next_Id = " & Trim(Str(Current_Household_Id_Int)) DoCmd.RunSQL (Update_Sql) End Sub Any ideas are very welcome! If I can get this bit working, I should be able to apply it to do in 8 other spots of code, and thus make some very hard-working, sweaty charity workers a bit happier. Sigh. Tia |
#3
| |||
| |||
|
#4
| |||
| |||
|
|
This code creates the next unique Household_Id (based on adding 1 to the last value added). The line where it breaks is: Household_Id_Recordset.Index = "PrimaryKey" |
#5
| |||
| |||
|
|
the reason it breaks is that table-type recordsets don't work with linked tables, which is naturally what I have after splitting. That's why splitting affected the code, and why I need to change it in several different places in the application. I knew how to use recordsets, more or less, and how handy that was! But now those forms are broken. |
#6
| |||
| |||
|
#7
| |||
| |||
|
|
I've never declared a type-type recordset nor used SEEK. |
#8
| |||
| |||
|
|
Thanks! It was INDEX! Like SEEK, it doesn't work with those linked tables, I guess. When Access links to external tables, the result is evidently always dynaset type, and dynaset doesn't play with Index. Or Seek, though I wasn't using it. I removed the index line and cleaned some other stuff up, and my form now works, as beautifully as before the split, with the code below. (I kind of wonder why I used the index property (method?) at all, way back when.) Option Compare Database Option Explicit Private Sub Form_Current() Dim dbs As Database Dim Current_Household_Id_String As String Dim Current_Household_Id_Int As Long Dim Household_Id_Recordset As Recordset Dim Household_Id_Table As TableDef Dim Update_Sql As String Set dbs = CurrentDb 'Open Next_Household_Id table Set Household_Id_Table = dbs.TableDefs("Next_Household_Id") Set Household_Id_Recordset = Household_Id_Table.OpenRecordset() 'Find out next household id Current_Household_Id_String = Household_Id_Recordset.Fields(0).Value 'Pad left with zeros Current_Household_Id_String = Right("000000" & Current_Household_Id_String, 6) 'Write Household ID into the form Me![Household_Id] = Current_Household_Id_String 'Add 1 to next household id table Current_Household_Id_Int = Val(Current_Household_Id_String) Current_Household_Id_Int = Current_Household_Id_Int + 1 Update_Sql = "UPDATE Next_Household_Id SET Next_Household_Id.Next_Id = " & Trim(Str(Current_Household_Id_Int)) DoCmd.RunSQL (Update_Sql) End Sub |
#9
| |||
| |||
|
|
After splitting the database, portions of code that use recordsets (now based on linked tables) don't work. Runtime error 3251 "Operation is not supported for this type of object." I've read past posts on the same issue, but I can't get any solutions to work. Self- taught amateur (so be gentle and use itty-bitty words, please). Even hard-coding the new BE would be fine, really! My users are trying to place folks in jobs and feed widows -- AND their air conditioning just died! I really need to fix this quickly. This code creates the next unique Household_Id (based on adding 1 to the last value added). The line where it breaks is: Household_Id_Recordset.Index = "PrimaryKey" The location of the BE is: D:\Client Statistical Database \ClientDatabase_BE.mdb Option Compare Database Option Explicit Private current_db As Database Private Household_Id_Recordset As Recordset Private Household_Id_Table As TableDef Private Sub Form_Current() Dim Current_Household_Id_String As String Dim Current_Household_Id_Int As Long Dim Update_Sql As String 'Open Next_Household_Id table Set current_db = CurrentDb() Set Household_Id_Table = current_db.TableDefs("Next_Household_Id") Set Household_Id_Recordset = Household_Id_Table.OpenRecordset() Household_Id_Recordset.Index = "PrimaryKey" 'Find out next household id Current_Household_Id_String = Household_Id_Recordset.Fields(0).Value 'Pad left with zeros Current_Household_Id_String = Right("000000" & Current_Household_Id_String, 6) 'Write household id into the form Me![Household_Id] = Current_Household_Id_String 'Add 1 to next household id table Current_Household_Id_Int = Val(Current_Household_Id_String) Current_Household_Id_Int = Current_Household_Id_Int + 1 Update_Sql = "UPDATE Next_Household_Id SET Next_Household_Id.Next_Id = " & Trim(Str(Current_Household_Id_Int)) DoCmd.RunSQL (Update_Sql) End Sub Any ideas are very welcome! If I can get this bit working, I should be able to apply it to do in 8 other spots of code, and thus make some very hard-working, sweaty charity workers a bit happier. Sigh. Tia |
#10
| |||
| |||
|
|
Thanks! It was INDEX! Like SEEK, it doesn't work with those linked tables, I guess. |
|
When Access links to external tables, the result is evidently always dynaset type, and dynaset doesn't play with Index. Or Seek, though I wasn't using it. I removed the index line and cleaned some other stuff up, and my form now works, as beautifully as before the split, with the code below. (I kind of wonder why I used the index property (method?) at all, way back when.) |
|
Option Compare Database Option Explicit Private Sub Form_Current() Dim dbs As Database Dim Current_Household_Id_String As String Dim Current_Household_Id_Int As Long Dim Household_Id_Recordset As Recordset Dim Household_Id_Table As TableDef Dim Update_Sql As String Set dbs = CurrentDb 'Open Next_Household_Id table Set Household_Id_Table = dbs.TableDefs("Next_Household_Id") Set Household_Id_Recordset = Household_Id_Table.OpenRecordset() 'Find out next household id Current_Household_Id_String = Household_Id_Recordset.Fields(0).Value 'Pad left with zeros Current_Household_Id_String = Right("000000" & Current_Household_Id_String, 6) 'Write Household ID into the form Me![Household_Id] = Current_Household_Id_String 'Add 1 to next household id table Current_Household_Id_Int = Val(Current_Household_Id_String) Current_Household_Id_Int = Current_Household_Id_Int + 1 Update_Sql = "UPDATE Next_Household_Id SET Next_Household_Id.Next_Id = " & Trim(Str(Current_Household_Id_Int)) DoCmd.RunSQL (Update_Sql) End Sub |
![]() |
| Thread Tools | |
| Display Modes | |
| |