Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Runtime Error 424 - Object Required...

Status
Not open for further replies.

sanders720

Programmer
Aug 2, 2001
421
US
I am trying to populate the same way with a variable, and it can't find the object...

B1(q).Value = "2"

This happens with either .Value or .Text... The B1(q) evaluates properly... Thanks in advance for any help you can provide...


Private Sub BUILDQUERY2()

Dim c As Integer
Dim q As Integer

B1 = Array("txtITJobNo", "txtVendor", "txtInvoiceNo", "txtRequestingUser", "txtAuthorizingUser", "txtPurchaseDate", _
"txtWarrantyDate", "txtManufacturer", "txtName", "txtPartNo", "txtSerialNo", "txtCDKey", _
"txtUpgrade", "txtQuantity", "txtSeats", "txtUser", "txtInstalledPC", "txtLicense", _
"txtPurchasedPrice")

For q = 1 To 19
If B(q) <> &quot;&quot; And B1(q) <> &quot;2&quot; Then
c = c + 1
If Len(OBJECT2) > 0 Then
OBJECT2 = OBJECT2 & &quot; and (&quot; & A(q) & &quot;= '&quot; & B(q) & &quot;'.Text)&quot;
Else
OBJECT2 = &quot;(&quot; & A(q) & &quot;= '&quot; & B(q) & &quot;'.Text)&quot;
End If
Debug.Print OBJECT2

B1(q).Value = &quot;2&quot;
B(q).Enabled = False

End If

Next q

End Sub
 
sanders:

What is the distinction between B(q) and B1(q)?

If your array is B1(), then B() is a non-defined variable which Access thinks is an array object, but has not reserved memory for.

HTH,

Vic
 
Option Base 1

Public A
Public B
Public B1


The arrays are defined as public at the beginning of the program. Is there something else I need to do within the event to reserve memory before using the variable, and what might it look like?

Thanks for the help on this!!!


 
sanders:

If you just declare the public variables as you've shown, then they all start out as type Variant, not arrays. Your code in Sub BUILDQUERY2() redefines B1 as an array and initializes its elements.

Where and how do you set the other variables A and B, declaring them as arrays and initializing their elements?

Do you do something similar to A and B elsewhere in your code?

Vic
 
Yes... A and B are defined at the FormLoad event.

Option Compare Database
Option Base 1

Public A
Public B
Public B1

Public OBJECT As String
Public OBJECT2 As String
Public OBJECT3 As String
Public OBJECT4 As String


Private Sub PopulateComboBoxes()
Dim rst As Recordset
Dim sql As String
Dim c As Integer
Dim x As Integer
Dim extprice As Currency

sql = &quot;SELECT * FROM qryInvoice&quot;

Set rst = CurrentDb.OpenRecordset(sql)


rst.Close
Set rst = Nothing

sql = &quot;SELECT qryInvoice.[Product Name], qryInvoice.[Product Manufacturer], qryInvoice.[Product Part Number], &quot; & _
&quot;qryInvoice.Quantity, qryInvoice.[Seats Covered], qryInvoice.[Purchase Price]&quot; & _
&quot;FROM qryInvoice &quot; & _
&quot;WHERE (((qryInvoice.[Invoice Number])= '&quot; & Me.cboInvoiceNumber.Text & &quot;'));&quot;

Set rst = CurrentDb.OpenRecordset(sql)
rst.MoveLast
c = rst.RecordCount
rst.MoveFirst

With msgPurchasedDetail

If .Rows > 1 Then
.Rows = 1
End If

For x = 1 To c
.Rows = .Rows + 1
.TextMatrix(.Rows - 1, 1) = rst(&quot;[Product Manufacturer]&quot;)
.TextMatrix(.Rows - 1, 2) = rst(&quot;[Product Name]&quot;)
.TextMatrix(.Rows - 1, 3) = rst(&quot;[Product Part Number]&quot;)
.TextMatrix(.Rows - 1, 4) = rst(&quot;Quantity&quot;)
.TextMatrix(.Rows - 1, 5) = rst(&quot;[Seats Covered]&quot;)
.TextMatrix(.Rows - 1, 6) = Format(rst(&quot;[Purchase Price]&quot;), &quot;$###0.00&quot;)
.TextMatrix(.Rows - 1, 7) = Format(.TextMatrix(.Rows - 1, 4) * .TextMatrix(.Rows - 1, 6), &quot;$###0.00&quot;)
rst.MoveNext

Next x
End With

rst.Close
Set rst = Nothing

End Sub


Private Sub cboAuthorizingUser_Click()
Me.txtAuthorizingUser.Value = &quot;1&quot;
BUILDQUERY2
REPOPULATE

End Sub

Private Sub cboCDKey_Click()
Me.txtCDKey.Value = &quot;1&quot;
BUILDQUERY2
REPOPULATE

End Sub

Private Sub cboExtendedPrice_Click()
Me.txtExtendedPrice.Value = &quot;1&quot;
BUILDQUERY2
REPOPULATE

End Sub

Private Sub cboInstalledPC_Click()
Me.txtInstalledPC.Value = &quot;1&quot;
BUILDQUERY2
REPOPULATE

End Sub

Private Sub cboInvoiceNo_Click()
Me.txtInvoiceNo.Value = &quot;1&quot;
BUILDQUERY2
REPOPULATE

End Sub

Private Sub cboITJobNo_Click()
Me.txtITJobNo.Value = &quot;1&quot;
BUILDQUERY2
REPOPULATE

End Sub

Private Sub cboLicense_Click()
Me.txtLicense.Value = &quot;1&quot;
BUILDQUERY2
REPOPULATE

End Sub

Private Sub cboManufacturer_Click()
Me.txtManufacturer.Value = &quot;1&quot;
BUILDQUERY2
REPOPULATE

End Sub

Private Sub cboName_Click()
Me.txtName.Value = &quot;1&quot;
BUILDQUERY2
REPOPULATE

End Sub

Private Sub cboPartNo_Click()
Me.txtPartNo.Value = &quot;1&quot;
BUILDQUERY2
REPOPULATE

End Sub

Private Sub cboPurchaseDate_Click()
Me.txtPurchaseDate.Value = &quot;1&quot;
BUILDQUERY2
REPOPULATE

End Sub

Private Sub cboPurchasedPrice_Click()
Me.txtPurchasedPrice.Value = &quot;1&quot;
BUILDQUERY2
REPOPULATE

End Sub

Private Sub cboQuantity_Click()
Me.txtQuantity.Value = &quot;1&quot;
BUILDQUERY2
REPOPULATE

End Sub

Private Sub cboRequestingUser_Click()
Me.txtRequestingUser.Value = &quot;1&quot;
BUILDQUERY2
REPOPULATE

End Sub

Private Sub cboSeats_Click()
Me.txtSeats.Value = &quot;1&quot;
BUILDQUERY2
REPOPULATE

End Sub

Private Sub cboSerialNo_Click()
Me.txtSerialNo.Value = &quot;1&quot;
BUILDQUERY2
REPOPULATE

End Sub

Private Sub cboUpgrade_Click()
Me.txtUpgrade.Value = &quot;1&quot;
BUILDQUERY2
REPOPULATE

End Sub

Private Sub cboUser_Click()
Me.txtUser.Value = &quot;1&quot;
BUILDQUERY
REPOPULATE

End Sub

Private Sub cboVendor_Click()
Me.txtVendor.Value = &quot;1&quot;
BUILDQUERY2
REPOPULATE

End Sub

Private Sub cboWarrantyDate_Click()
Me.txtWarrantyDate.Value = &quot;1&quot;
BUILDQUERY2
REPOPULATE

End Sub

Private Sub Form_Load()

Dim x As String
Dim c As Integer
Dim q As Integer
Dim sql As String
Dim rs As ADODB.Recordset

With msgPurchasedDetail

.Rows = 1
.Cols = 21

.ColWidth(0) = 0
.ColWidth(1) = 600
.ColWidth(2) = 2000
.ColWidth(3) = 1000
.ColWidth(4) = 1500
.ColWidth(5) = 1500
.ColWidth(6) = 800
.ColWidth(7) = 800
.ColWidth(8) = 2200
.ColWidth(9) = 2400
.ColWidth(10) = 1800
.ColWidth(11) = 2000
.ColWidth(12) = 2200
.ColWidth(13) = 600
.ColWidth(14) = 600
.ColWidth(15) = 600
.ColWidth(16) = 1600
.ColWidth(17) = 1600
.ColWidth(18) = 2200
.ColWidth(19) = 900
.ColWidth(20) = 1000

For q = 0 To 19
.ColAlignment(c) = 1
Next q

.TextMatrix(0, 1) = &quot;IT Job No.&quot;
.TextMatrix(0, 2) = &quot;Vendor&quot;
.TextMatrix(0, 3) = &quot;Inv No.&quot;
.TextMatrix(0, 4) = &quot;Req User&quot;
.TextMatrix(0, 5) = &quot;Auth User&quot;
.TextMatrix(0, 6) = &quot;Purch Date&quot;
.TextMatrix(0, 7) = &quot;Warr Date&quot;
.TextMatrix(0, 8) = &quot;Manufacturer&quot;
.TextMatrix(0, 9) = &quot;Name&quot;
.TextMatrix(0, 10) = &quot;Part No.&quot;
.TextMatrix(0, 11) = &quot;Serial No.&quot;
.TextMatrix(0, 12) = &quot;CD Key&quot;
.TextMatrix(0, 13) = &quot;Upgr&quot;
.TextMatrix(0, 14) = &quot;Qty&quot;
.TextMatrix(0, 15) = &quot;Seats&quot;
.TextMatrix(0, 16) = &quot;User&quot;
.TextMatrix(0, 17) = &quot;Inst PC&quot;
.TextMatrix(0, 18) = &quot;License&quot;
.TextMatrix(0, 19) = &quot;Purch Price&quot;
.TextMatrix(0, 20) = &quot;Ext Price&quot;

End With

Set rs = New ADODB.Recordset

A = Array(&quot;[IT Job Number]&quot;, &quot;Vendor&quot;, &quot;[Invoice Number]&quot;, &quot;[Requesting User]&quot;, &quot;[Authorizing User]&quot;, &quot;[Purchase Date]&quot;, _
&quot;[Warranty End Date]&quot;, &quot;[Product Manufacturer]&quot;, &quot;[Product Name]&quot;, &quot;[Product Part Number]&quot;, &quot;[Product Serial Number]&quot;, &quot;[CD Key]&quot;, _
&quot;[Upgrade Flag]&quot;, &quot;Quantity&quot;, &quot;[Seats Covered]&quot;, &quot;[User Assignment]&quot;, &quot;[Installed PC Name]&quot;, &quot;[Product License Number]&quot;, _
&quot;[Purchase Price]&quot;)

B = Array(&quot;cboITJobNo&quot;, &quot;cboVendor&quot;, &quot;cboInvoiceNo&quot;, &quot;cboRequestingUser&quot;, &quot;cboAuthorizingUser&quot;, &quot;cboPurchaseDate&quot;, _
&quot;cboWarrantyDate&quot;, &quot;cboManufacturer&quot;, &quot;cboName&quot;, &quot;cboPartNo&quot;, &quot;cboSerialNo&quot;, &quot;cboCDKey&quot;, _
&quot;cboUpgrade&quot;, &quot;cboQuantity&quot;, &quot;cboSeats&quot;, &quot;cboUser&quot;, &quot;cboInstalledPC&quot;, &quot;cboLicense&quot;, _
&quot;cboPurchasedPrice&quot;)

For q = 1 To 19
Debug.Print A(q)
Debug.Print B(q)

sql = &quot;SELECT qrySoftwareTracking.&quot; & A(q) & &quot; FROM qrySoftwareTracking;&quot;
Debug.Print sql

' Forms!frmSoftwareTracking(B(q)).RowSource = sql (syntax for modules)
Me(B(q)).RowSource = sql

' The following code is not necessary, but is good syntax reference for ADO
With rs
.CursorLocation = adUseClient
.Open sql, CurrentProject.Connection, adOpenDynamic, adLockOptimistic
.MoveLast
c = .RecordCount
Debug.Print c
.MoveFirst

.Update
.Close

End With
Next q

Set rs = Nothing

End Sub

Private Sub BUILDQUERY()

Dim c As Integer
Dim q As Integer

Dim pL As String
Dim pR As String

For q = 1 To 19

If B1(q).Text <> &quot;2&quot; Then Me.B(q).Clear

If B(q) <> &quot;&quot; Then
c = c + 1
If Len(OBJECT) > 0 Then
OBJECT = OBJECT & &quot; and (&quot; & A(q) & &quot;= '&quot; & B(q) & &quot;'.Text)&quot;
Else
OBJECT = &quot;(&quot; & A(q) & &quot;= '&quot; & B(q) & &quot;'.Text)&quot;
End If
Debug.Print OBJECT

End If

Next q

For q = 2 To c
pL = pL & &quot;(&quot;
pR = pR & &quot;)&quot;
Next q

OBJECT = pL & OBJECT & pR

End Sub

Private Sub BUILDQUERY2()

Dim c As Integer
Dim q As Integer

B1 = Array(&quot;txtITJobNo&quot;, &quot;txtVendor&quot;, &quot;txtInvoiceNo&quot;, &quot;txtRequestingUser&quot;, &quot;txtAuthorizingUser&quot;, &quot;txtPurchaseDate&quot;, _
&quot;txtWarrantyDate&quot;, &quot;txtManufacturer&quot;, &quot;txtName&quot;, &quot;txtPartNo&quot;, &quot;txtSerialNo&quot;, &quot;txtCDKey&quot;, _
&quot;txtUpgrade&quot;, &quot;txtQuantity&quot;, &quot;txtSeats&quot;, &quot;txtUser&quot;, &quot;txtInstalledPC&quot;, &quot;txtLicense&quot;, _
&quot;txtPurchasedPrice&quot;)

For q = 1 To 19
If B(q) <> &quot;&quot; And B1(q) <> &quot;2&quot; Then
c = c + 1
If Len(OBJECT2) > 0 Then
OBJECT2 = OBJECT2 & &quot; and (&quot; & A(q) & &quot;= '&quot; & B(q) & &quot;'.Text)&quot;
Else
OBJECT2 = &quot;(&quot; & A(q) & &quot;= '&quot; & B(q) & &quot;'.Text)&quot;
End If
Debug.Print OBJECT2

B1(q).Value = &quot;2&quot;
B(q).Enabled = False

End If

Next q

End Sub

Private Sub REPOPULATE()

Dim rs As Recordset
Dim q As Integer
Dim c As Integer

Set rs = New ADODB.Recordset

For q = 1 To 19
With rs
OBJECT3 = &quot;SELECT qrySoftwareTracking.* FROM qrySoftwareTracking WHERE 1=1 AND (&quot; & OBJECT2
Debug.Print OBJECT3

' Forms!frmSoftwareTracking(B(q)).RowSource = OBJECT3 (syntax for modules)
Me(B(q)).RowSource = OBJECT3

End With

Next q

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top