|
-
Sep 15th, 2005, 10:57 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] Another Access VBA RS Question
I am getting an invalid operation error on the underlined section of code. I cant understand it im copying straight from a book for this stuff and the book always seems to be wrong.
VB Code:
rs.Open strSQL, cnn, adOpenDynamic, adLockOptimistic, adCmdText
StatetoAdd = Me.lstStateList.ListIndex
With rs
[U].AddNew[/U]!FK_State = StatetoAdd
.Update
.Close
Populate_lstEmpStates
End With
-
Sep 15th, 2005, 12:54 PM
#2
Re: Another Access VBA RS Question

VB Code:
rs.Open strSQL, cnn, adOpenDynamic, adLockOptimistic, adCmdText
StatetoAdd = Me.lstStateList.ListIndex
With rs
.AddNew
.Fields("FK_State").Value = StatetoAdd
.Update
.Close
Populate_lstEmpStates
End With
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 16th, 2005, 03:20 AM
#3
Thread Starter
Frenzied Member
Re: Another Access VBA RS Question
I still get the error Invalid operation on the .AddNew Line
VB Code:
rs.Open strSQL, cnn, adOpenDynamic, adLockOptimistic, adCmdText
StatetoAdd = Me.lstStateList.ListIndex
With rs
.AddNew
.Fields("FK_State").Value = StatetoAdd
.Update
.Close
Populate_lstEmpStates
End With
-
Sep 16th, 2005, 03:35 AM
#4
Thread Starter
Frenzied Member
Re: Another Access VBA RS Question
I have changes the underlying record sets SQL to a more simlple - select star from employee states which clears the above error but sticks on the .update line with ODBC call failed. any ideas..
-
Sep 16th, 2005, 03:51 AM
#5
Re: Another Access VBA RS Question
Are there other fields in the table which need to be set? (ie: do not allow Null)
If so, you'll need to add more lines like .Fields("FK_State").Value = StatetoAdd
-
Sep 16th, 2005, 04:03 AM
#6
Thread Starter
Frenzied Member
Re: Another Access VBA RS Question
Yes Si that was the problem... Cheers.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|