473,411 Members | 1,923 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,411 software developers and data experts.

probleum in inserting empty records

198 100+
Hi
i have a mdb table in which i want to access the data from mdb table into new table i,e Operator but the condition is if the data in first row of column say "operator_code" is "alfred" . The name alfred is inserted into operator
OK
and when i move to the next row in the column i,e "operator_code"
lets assume it is empty in that case the value of previous row i,e "alfred" must be inserted into the empty row
i create a loop but it is not working for empty record
Expand|Select|Wrap|Line Numbers
  1. For reccount = 1 To rsmaster.RecordCount
  2. If Not IsNull rsmaster.Fields("Yp1VOp") Then
  3. YpVcode = rsmaster.Fields("Yp1VOp")
  4. squery = "insert into operator values( ' " & YpVcode & " ' )"
  5. dbmaster.Execute (squery)
  6. Else
  7. squery = "insert into operator values( ' " & YpVcode & " ' )"
  8. dbmaster.Execute (squery)
  9.  
  10. End If
  11. rsmaster.MoveNext
  12. Next
please give me help
best regards
varinder
Apr 17 '08 #1
7 1296
debasisdas
8,127 Expert 4TB
Once you move to tthe next record how it will access the previous record. You need to store the previous record in a variable and check the next rerord. Continue this is a loop till the last record.
Apr 17 '08 #2
veer
198 100+
Hi
i stored the value in a variable named "YpvCode"
and i used this condition

For reccount = 1 To rsmaster.RecordCount
If rsmaster.Fields("Yp1VOp") <> "" Then
YpVcode = rsmaster.Fields("Yp1VOp")
squery = "insert into operator values( ' " & YpVcode & " ' )"
dbmaster.Execute (squery)
Else
squery = "insert into operator values( ' " & YpVcode & " ' )"
dbmaster.Execute (squery)
End If
rsmaster.MoveNext
Next

but when the empty record came, the control is not moving on to else condition
how is it possible
please check the condition and give me suggestion






Once you move to tthe next record how it will access the previous record. You need to store the previous record in a variable and check the next rerord. Continue this is a loop till the last record.
Apr 17 '08 #3
debasisdas
8,127 Expert 4TB
Check if the record is empty or contains spaces.
Apr 17 '08 #4
veer
198 100+
Hi
the record is empty there is not space because
i am accessing mdb file
the first row of column contain data"alfred"
the 2nd row of column is empty and i want the data from first row of that column in 2nd row of column




Check if the record is empty or contains spaces.
Apr 17 '08 #5
debasisdas
8,127 Expert 4TB
Have you tried as suggested in post #2.
Apr 17 '08 #6
veer
198 100+
yes i tried it

For icount =1 to rsmaster.recordcount
If rsmaster.Fields("Yp1VOp") <> "" Then
YpVcode = rsmaster.Fields("Yp1VOp") \\stored value in ypvcode
squery = "insert into operator values( ' " & YpVcode & " ' )
dbmaster.Execute (squery)
Else
squery = "insert into operator values( ' " & YpVcode & " ' )"
dbmaster.Execute (squery)
End If
rsmaster.MoveNext
Next

In next step the field is empty i want the value from YpVCode in the empty field
but when the empty field came it is not following
rsmaster.Fields("Yp1VOp") <> "" condtion but i want it jump and directly goto else condition


Have you tried as suggested in post #2.
Apr 17 '08 #7
debasisdas
8,127 Expert 4TB
try like this

YpVcode= iif(isnull(rsmaster.Fields("Yp1VOp")),null,rsmaste r.Fields("Yp1VOp"))


and since you are eecuting the same code why using IF....ELSE
Apr 17 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: Miranda | last post by:
Hi, I have a ASP/vbscript program that generates random passwords. The problem is I need to insert those passwords into an Access database of 327 clients. I have the random password program...
0
by: GreenFROG Design | last post by:
Data Processing and SQL INSERTING Hello guy's i'm faced with a horrible dilemma i have whole dictionary that i have to enter into a database. I have all the text and i would like to convert it...
2
by: FizzBin | last post by:
We are writing a C application that is using ODBC to insert records into a database. We have a NOT NULL column that can legitimately have an empty value, i.e. we know the value and it is empty...
6
by: Pushpendra Vats | last post by:
Hi , I am trying to insert records into database. I am trying to write the following code. On button1 click event i am inserting five records and after that i am calling the update method of...
7
by: Dabbler | last post by:
I'm using an ObjectDataSource with a stored procedure and am getting the following error when trying to update (ExecuteNonQuery): System.Data.SqlClient.SqlException: Procedure or Function...
2
by: veer | last post by:
hello expert i made a website which opens in ie6 and works fine but when i open it in ie7 it creates probleum the probleum is that i have a footer in my webpage , it automatically moves in the...
2
by: AlexanderDeLarge | last post by:
Hi! I got a problem that's driving me crazy and I'm desperately in need of help. I'll explain my scenario: I'm doing a database driven site for a band, I got these tables for their discography...
1
by: veer | last post by:
hi i think it's a silly question but i am very confused about this actually i made program on spell check.This is done by creating object of msword and then with the help of this object i create...
5
by: rando1000 | last post by:
Okay, here's my situation. I need to loop through a file, inserting records based on a number field (in order) and if the character in a certain field = "##", I need to insert a blank record. ...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.