Need Urgent Solution

Reply

Join Date: Mar 2005
Posts: 18
Reputation: Raza is an unknown quantity at this point 
Solved Threads: 0
Raza Raza is offline Offline
Newbie Poster

Need Urgent Solution

 
0
  #1
Oct 15th, 2005
Hello e/one,
im getting error no. 9 "subscript out of range" in following situation.


- i have a data grid on page on which i place a query to select data from SQL SERVER 2000 database just like that "select size_number, product_size, type_number from product_size"

-Below this grid i have 2 textboxes and 1 combobox.

-Now i want to show same data appear in data grid at the same time, user clicks on any row of datagrid. the user clicks in datagrid, the data of same row will be shown below in textboxes and combo.(type_number is in combo)

-Now its working successfully if i places only 2 things (i.e. text boxes)
when i add third item (combobox) it produces error...

-Can anyone HELP me...........its urgent...im showing some code here...

####Code Starts######
Option Explicit
Dim clscombo As New clsfillcombo

Private Sub cmdclose_Click()
Unload frmsize
Unload frmcategory
Unload frmproduct
Unload frmsupplier
frmwelcome.Show
End Sub

Private Sub cmddelete_Click()
On Error GoTo error_Delete
Dim rs As ADODB.Recordset
Dim sSql As String
Dim strtypenumber As String
If MsgBox("Are you sure you want to delete the selected record?", vbQuestion + vbYesNo + vbDefaultButton2, "TR") = vbYes Then
sSql = "Delete from product_size where size_number= '" & dgsize.Columns(0).Text & "'"
cn.Execute sSql
Set rs = Nothing
MDIForm1.Adodc1.Refresh
dgsize.Refresh
End If
Exit Sub
error_Delete:
If Err.Number = -2147217900 Then
MsgBox "This Size is in used, It cannot be deleted.", vbExclamation, "TR"
End If
End Sub

Private Sub cmdedit_Click()

txtnumber.Enabled = True
txtname.Enabled = True
cbotype.Enabled = True
cmdupdate.Visible = True
End Sub

Private Sub cmdnew_Click()
frmnewsize.Show

End Sub

Private Sub cmdupdate_Click()
'On Error GoTo error_update
With MDIForm1.Adodc1
.Recordset.Fields("size_number").Value = frmsize.txtnumber
.Recordset.Fields("product_size").Value = frmsize.txtname
.Recordset.Fields("type_number").Value = frmsize.cbotype
.Recordset.Update
MsgBox "Record has been Updated Successfully", vbInformation, "TR"
txtnumber.Enabled = False
txtname.Enabled = False
cbotype.Enabled = False
cmdupdate.Visible = False
End With
setDataGrid

'error_update:
'MsgBox Err.Description, vbInformation, "TR"
End Sub

Private Sub dgsize_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
setDataGrid
End Sub

Private Sub Form_Load()
On Error GoTo load_error
clscombo.fillProductType cbotype, cn
With MDIForm1.Adodc1
.RecordSource = "select * from product_size"
.Refresh
Set dgsize.DataSource = MDIForm1.Adodc1
dgsize.Refresh
End With
setDataGrid
txtnumber.Enabled = False
txtname.Enabled = False
cbotype.Enabled = False
cmdupdate.Visible = False

load_error:
If Err.Number = 6160 Then
MsgBox Err.Description, vbInformation, "TR"
cmdedit.Enabled = False
cmddelete.Enabled = False
End If
End Sub
Private Function setDataGrid()
With dgsize
txtnumber.Text = .Columns(1).Text '######working here
txtname.Text = .Columns(2).Text '######working here
cbotype.Text = .Columns(3).Text '######Now producing ERROR 9 here after adding this 1 line code

End With
End Function

Private Function invalidupdate() As Boolean
If Trim(txtnumber.Text) = "" Then
MsgBox "Size Number is invalid", vbInformation, "T.R. TRADERS"
invalidupdate = True
txtnumber.SetFocus
Exit Function

ElseIf Trim(txtname.Text) = "" Then
MsgBox "Product Size is invalid", vbInformation, "T.R. TRADERS"
invalidupdate = True
txtname.SetFocus
Exit Function
End If
End Function

Private Sub Form_Unload(Cancel As Integer)
Set clscombo = Nothing
End Sub


####Code Ends#######
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 70
Reputation: w00dy is an unknown quantity at this point 
Solved Threads: 2
w00dy w00dy is offline Offline
Junior Poster in Training

Re: Need Urgent Solution

 
0
  #2
Oct 16th, 2005
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 18
Reputation: Raza is an unknown quantity at this point 
Solved Threads: 0
Raza Raza is offline Offline
Newbie Poster

Re: Need Urgent Solution

 
0
  #3
Oct 17th, 2005
no change.........
if u can make change in my code to work properly then plz.....

Thanks alot.
Raza.



Originally Posted by w00dy
This may help:

http://msdn.microsoft.com/library/de...utofbounds.asp
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC