Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 21st, 2009, 03:59 PM
Authorized User
 
Join Date: Jan 2009
Posts: 20
Thanks: 5
Thanked 0 Times in 0 Posts
Default retrieving row with reference of Null value

Can any one please help me?? Using VB 6.0 and Access DB.
Code:
ssql2 = "INSERT INTO JanuaryDay (JanRm_id) SELECT rmd_id FROM RmIdIndex WHERE rm_id= " & CLng(txtrostermid.Text)
    rsName.Open ssql2, conName, adOpenDynamic, adLockOptimistic
    rsmnth.Open "select * from JanuaryDay", conName, 3, 3
rsmnth.MoveFirst
Do While Not rsmnth.EOF
	‘here is the problem.                                                              
If rsmnth("JanRm_id") = txtrmdid.Text And rsmnth("JanDate") = Null Then
‘in DB JanRm_id(column) of JanuaryDay(table) will contain duplicate value. ‘That’s what after inserting data in JanRm_id I want to pick the row which ‘having data in JanRm_id and no data in JanDate, so that I can input data in ‘that specific row. Cannot use UPDATE command coz JanRm_id have duplicate ‘value.
‘Same thing I did with number data type. Like:

‘ssql2 = "INSERT INTO UserOfTheMonth (emp_id) SELECT Emp_id FROM ‘users where Name='" & CboName.Text & "'"
‘    rsName.Open ssql2, conName, adOpenDynamic, adLockOptimistic
‘rsmnth.Open "select * from UserOfTheMonth", conName, 3, 3
‘rsmnth.MoveFirst
‘Do While Not rsmnth.EOF
‘If rsmnth("year") = 0 And rsmnth("emp_id") = TxtEmpId.Text Then
‘txtrostermid.Text = rsmnth("rosterm_id")
‘rsmnth.Fields("month").Value = Trim(Cbomnth.Text)
‘rsmnth.Fields("year").Value = Val(Cboyear.Text)
‘rsmnth.Update
‘End If
‘  rsmnth.MoveNext
‘   Loop

‘Here year(column) of UserOfTheMonth having number data type. But above ‘one (rsmnth("JanDate") = Null) is having Text data type.

‘Vary new with VB6.0. Hitting my head to wall for the last 2 days.
‘Can any one help me please
rsmnth.Fields("JanDate").Value = Trim(Label1.Caption)
rsmnth.Fields("JanShift").Value = Trim(Combo1.Text)
rsmnth.Update
End If
  rsmnth.MoveNext
   Loop
    End If
regards
 
Old February 21st, 2009, 04:54 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Would you be so kind of explain a little better your problem?

Also please separate your comments from your code, is hard to follow you this way.
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
Null reference exception was unhandled labby C# 2005 0 April 24th, 2007 06:14 AM
Null reference issue Abbas C# 1 March 19th, 2007 11:39 PM
Null Reference Exception was unhandled labby C# 2005 1 February 9th, 2007 03:15 PM
Null reference exception when using DataAdapter Samantha Karen Webb C# 1 July 21st, 2006 09:12 AM
NULL reference exception Dwizz VB.NET 2002/2003 Basics 3 June 21st, 2005 07:15 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.