By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,948 Members | 865 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,948 IT Pros & Developers. It's quick & easy.

probleum in inserting empty records

100+
P: 198
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
Share this Question
Share on Google+
7 Replies


debasisdas
Expert 5K+
P: 8,127
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

100+
P: 198
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
Expert 5K+
P: 8,127
Check if the record is empty or contains spaces.
Apr 17 '08 #4

100+
P: 198
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
Expert 5K+
P: 8,127
Have you tried as suggested in post #2.
Apr 17 '08 #6

100+
P: 198
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
Expert 5K+
P: 8,127
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

Post your reply

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