473,395 Members | 1,608 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

struggling with recordset code

I have an unbound form for adding assets, everything works OK till the
line:
..AddNew
where I get a 424 / Object required Runtime Error.... anyone have any
clues?... thanks!!!

Option Compare Database

Private Sub CloseForm_Click()
On Error GoTo Err_CloseForm_Click
DoCmd.Close
Exit_CloseForm_Click:
Exit Sub
Err_CloseForm_Click:
MsgBox Err.Description
Resume Exit_CloseForm_Click
End Sub

Private Sub cboAssetType_GotFocus()
DoCmd.Requery "cboAssetType"
End Sub
Private Sub Form_Open(Cancel As Integer)
strSQL1 = "SELECT Assets.* FROM Assets WHERE (((Assets.[Asset
Number]) Is Null))"
Set mrstADO1 = New ADODB.Recordset
mrstADO1.Open strSQL1, CurrentProject.Connection, adOpenStatic,
adLockOptimistic
End Sub

Private Sub GetNewNumber_Click()
'If Me.NewRecord Then
Me![Asset Number] = Nz(DMax("[Asset Number]", "Assets",
"[AssetType] = '" & Me!cboAssetType & "'")) + 1
'End If
End Sub

Private Sub Form_Load()
DoCmd.MoveSize 400, 800, 14500, 8500
End Sub

Private Sub SaveRecord_Click()
With mrstADO1
.AddNew
.Fields("Mfg") = Me.cboMfg
.Fields("Asset Type") = Me.cboAssetType
.Fields("Asset Number") = Me.[Asset Number]
.Fields("Model/Part Number") = Me.[Model/Part Number]
.Fields("Description") = Me.Description
.Fields("Serial Number") = Me.[Serial Number]
.Fields("Location") = Me.Location
.Fields("Sub-Location") = Me.[Sub-Location]
.Fields("InServiceDate") = Me.InServiceDate
.Fields("Status") = Me.cboStatus
.Fields("LRT/SPEC Barcode Number") = Me.[LRT/SPEC Barcode
Number]
.Fields("Comments") = Me.Comments
.Fields("WorkstationID") = Me.WorkstationID
.Fields("ComputerName") = Me.ComputerName
.Fields("PrimaryUser") = Me.PrimaryUser
.Fields("RAM") = Me.RAM
.Fields("Monitor") = Me.Monitor
.Fields("Covered by") = Me.[cboCovered by]
.Fields("Coverage Description") = Me.[Coverage Description]
.Fields("Warranty/Maintenance") = Me.[Warranty/Maintenance]
.Fields("PurchaseOrderNumber") = Me.PurchaseOrderNumber
.Fields("DMSname") = Me.DMSname
.Fields("NameNetworkName") = Me.NameNetworkName
.Fields("IPaddress") = Me.IPaddress
.Fields("SwitchPort") = Me.SwitchPort
.Fields("WallPort") = Me.WallPort
.Fields("MACaddress") = Me.MACaddress
.Fields("SpectralinkExtension") = Me.SpectralinkExtension
.Fields("PMInterval") = Me.PMInterval
.Fields("LastPMdate") = Me.LastPMdate
.Fields("Replacement Cost") = Me.[Replacement Cost]
.Fields("Printer") = Me.Printer
.Fields("Peripherals") = Me.Peripherals
.Fields("CPUspeed") = Me.CPUspeed
.Fields("HDsize") = Me.HDsize
.Fields("CDDVD") = Me.CDDVD
.Update
End With
End Sub

Mar 23 '07 #1
2 1387
On Mar 23, 8:45 am, "slinky" <campbellbrian2...@yahoo.comwrote:
I have an unbound form for adding assets, everything works OK till the
line:
.AddNew
where I get a 424 / Object required Runtime Error.... anyone have any
clues?... thanks!!!

Option Compare Database

Private Sub CloseForm_Click()
On Error GoTo Err_CloseForm_Click
DoCmd.Close
Exit_CloseForm_Click:
Exit Sub
Err_CloseForm_Click:
MsgBox Err.Description
Resume Exit_CloseForm_Click
End Sub

Private Sub cboAssetType_GotFocus()
DoCmd.Requery "cboAssetType"
End Sub
Private Sub Form_Open(Cancel As Integer)
strSQL1 = "SELECT Assets.* FROM Assets WHERE (((Assets.[Asset
Number]) Is Null))"
Set mrstADO1 = New ADODB.Recordset
mrstADO1.Open strSQL1, CurrentProject.Connection, adOpenStatic,
adLockOptimistic
End Sub

Private Sub GetNewNumber_Click()
'If Me.NewRecord Then
Me![Asset Number] = Nz(DMax("[Asset Number]", "Assets",
"[AssetType] = '" & Me!cboAssetType & "'")) + 1
'End If
End Sub

Private Sub Form_Load()
DoCmd.MoveSize 400, 800, 14500, 8500
End Sub

Private Sub SaveRecord_Click()
With mrstADO1
.AddNew
.Fields("Mfg") = Me.cboMfg
.Fields("Asset Type") = Me.cboAssetType
.Fields("Asset Number") = Me.[Asset Number]
.Fields("Model/Part Number") = Me.[Model/Part Number]
.Fields("Description") = Me.Description
.Fields("Serial Number") = Me.[Serial Number]
.Fields("Location") = Me.Location
.Fields("Sub-Location") = Me.[Sub-Location]
.Fields("InServiceDate") = Me.InServiceDate
.Fields("Status") = Me.cboStatus
.Fields("LRT/SPEC Barcode Number") = Me.[LRT/SPEC Barcode
Number]
.Fields("Comments") = Me.Comments
.Fields("WorkstationID") = Me.WorkstationID
.Fields("ComputerName") = Me.ComputerName
.Fields("PrimaryUser") = Me.PrimaryUser
.Fields("RAM") = Me.RAM
.Fields("Monitor") = Me.Monitor
.Fields("Covered by") = Me.[cboCovered by]
.Fields("Coverage Description") = Me.[Coverage Description]
.Fields("Warranty/Maintenance") = Me.[Warranty/Maintenance]
.Fields("PurchaseOrderNumber") = Me.PurchaseOrderNumber
.Fields("DMSname") = Me.DMSname
.Fields("NameNetworkName") = Me.NameNetworkName
.Fields("IPaddress") = Me.IPaddress
.Fields("SwitchPort") = Me.SwitchPort
.Fields("WallPort") = Me.WallPort
.Fields("MACaddress") = Me.MACaddress
.Fields("SpectralinkExtension") = Me.SpectralinkExtension
.Fields("PMInterval") = Me.PMInterval
.Fields("LastPMdate") = Me.LastPMdate
.Fields("Replacement Cost") = Me.[Replacement Cost]
.Fields("Printer") = Me.Printer
.Fields("Peripherals") = Me.Peripherals
.Fields("CPUspeed") = Me.CPUspeed
.Fields("HDsize") = Me.HDsize
.Fields("CDDVD") = Me.CDDVD
.Update
End With
End Sub
It clearly does not know what mrstADO1 is. You must either declare
mrstADO1 at module level or pass it to the routine for it to know
what it is. One way to do this is to put the following in your module
declarations:
dim mrstADO1 as adodb.recordset
Even
private mrstADO1 as adodb.recordset will wrok

Good luck.

Mar 23 '07 #2
Are there any more straight forward ways for this newbie to get a data
entry form to avoid a save without hitting my Save button? HELP!!!

On Mar 23, 11:54 am, eng...@ridesoft.com wrote:
On Mar 23, 8:45 am, "slinky" <campbellbrian2...@yahoo.comwrote:


I have an unbound form for adding assets, everything works OK till the
line:
.AddNew
where I get a 424 / Object required Runtime Error.... anyone have any
clues?... thanks!!!
Option Compare Database
Private Sub CloseForm_Click()
On Error GoTo Err_CloseForm_Click
DoCmd.Close
Exit_CloseForm_Click:
Exit Sub
Err_CloseForm_Click:
MsgBox Err.Description
Resume Exit_CloseForm_Click
End Sub
Private Sub cboAssetType_GotFocus()
DoCmd.Requery "cboAssetType"
End Sub
Private Sub Form_Open(Cancel As Integer)
strSQL1 = "SELECT Assets.* FROM Assets WHERE (((Assets.[Asset
Number]) Is Null))"
Set mrstADO1 = New ADODB.Recordset
mrstADO1.Open strSQL1, CurrentProject.Connection, adOpenStatic,
adLockOptimistic
End Sub
Private Sub GetNewNumber_Click()
'If Me.NewRecord Then
Me![Asset Number] = Nz(DMax("[Asset Number]", "Assets",
"[AssetType] = '" & Me!cboAssetType & "'")) + 1
'End If
End Sub
Private Sub Form_Load()
DoCmd.MoveSize 400, 800, 14500, 8500
End Sub
Private Sub SaveRecord_Click()
With mrstADO1
.AddNew
.Fields("Mfg") = Me.cboMfg
.Fields("Asset Type") = Me.cboAssetType
.Fields("Asset Number") = Me.[Asset Number]
.Fields("Model/Part Number") = Me.[Model/Part Number]
.Fields("Description") = Me.Description
.Fields("Serial Number") = Me.[Serial Number]
.Fields("Location") = Me.Location
.Fields("Sub-Location") = Me.[Sub-Location]
.Fields("InServiceDate") = Me.InServiceDate
.Fields("Status") = Me.cboStatus
.Fields("LRT/SPEC Barcode Number") = Me.[LRT/SPEC Barcode
Number]
.Fields("Comments") = Me.Comments
.Fields("WorkstationID") = Me.WorkstationID
.Fields("ComputerName") = Me.ComputerName
.Fields("PrimaryUser") = Me.PrimaryUser
.Fields("RAM") = Me.RAM
.Fields("Monitor") = Me.Monitor
.Fields("Covered by") = Me.[cboCovered by]
.Fields("Coverage Description") = Me.[Coverage Description]
.Fields("Warranty/Maintenance") = Me.[Warranty/Maintenance]
.Fields("PurchaseOrderNumber") = Me.PurchaseOrderNumber
.Fields("DMSname") = Me.DMSname
.Fields("NameNetworkName") = Me.NameNetworkName
.Fields("IPaddress") = Me.IPaddress
.Fields("SwitchPort") = Me.SwitchPort
.Fields("WallPort") = Me.WallPort
.Fields("MACaddress") = Me.MACaddress
.Fields("SpectralinkExtension") = Me.SpectralinkExtension
.Fields("PMInterval") = Me.PMInterval
.Fields("LastPMdate") = Me.LastPMdate
.Fields("Replacement Cost") = Me.[Replacement Cost]
.Fields("Printer") = Me.Printer
.Fields("Peripherals") = Me.Peripherals
.Fields("CPUspeed") = Me.CPUspeed
.Fields("HDsize") = Me.HDsize
.Fields("CDDVD") = Me.CDDVD
.Update
End With
End Sub

It clearly does not know what mrstADO1 is. You must either declare
mrstADO1 at module level or pass it to the routine for it to know
what it is. One way to do this is to put the following in your module
declarations:
dim mrstADO1 as adodb.recordset
Even
private mrstADO1 as adodb.recordset will wrok

Good luck.- Hide quoted text -

- Show quoted text -

Mar 24 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: dmiller23462 | last post by:
My brain is nuked....Can anybody tell me right off the bat what is wrong with this code? Along with any glaring errors, please let me know the syntax to display a message (Response.Write would be...
19
by: Adam Short | last post by:
I am trying to write a routine that will connect a .NET server with a classic ASP server. I know the following code doesn't work! The data is being returned as a dataset, however ASP does not...
36
by: kjvt | last post by:
Based on a prior posting, I've written a function to convert a recordset to a dataview. The first call to the function for a given recordset works perfectly, but the second call always returns a...
0
ADezii
by: ADezii | last post by:
Most Access Users realize that Recordsets, being virtual representations of a Query, Table, or SQL Statement, exist only in our PC's memory. They, and the data they contain, literally exist at one...
0
ADezii
by: ADezii | last post by:
When you create an ADO Recordset, you should have some idea as to what functionality the Recordset does/does not provide. Some critical questions may, and should, be: Can I add New Records to the...
2
by: wallconor | last post by:
Hi, I am having a problem using Dreamweaver CS3 standard recordset paging behavior. It doesn’t seem to work when I pass parameter values from a FORM on my search page, to the recordset on my...
4
by: =?Utf-8?B?R1ROMTcwNzc3?= | last post by:
Hi Guys, thanks for your help yesterday, I've got one more question, then I think I'm done for now,... Is it possible to insert recordset data in a javascript, for instance I have a javascript...
3
by: mgsmario | last post by:
Hi Guys I have an ASP application that connects to an Oracle database, right now I'm trying to connect this same ASP application to a DB2 database (Express-C, version 9.5.0). I'm in the process...
0
by: mgsmario | last post by:
Hi Guys I have an ASP application that connects to an Oracle database, right now I'm trying to connect this same ASP application to a DB2 database (Express-C, version 9.5.0). I'm in the process...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.