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

for loop on form(Datasheetview) , need help

I have a subform with a loop to check to make sure 1 of the values in the textbox [CallType] = "N/A" before saving, but I can't seem to finish it, , well get it just to check for 1 N/A value, here is what I have :
Expand|Select|Wrap|Line Numbers
  1. Dim rst As DAO.Recordset
  2.  
  3. Set rst = Me.CallType
  4.  
  5. Do Until .EOF
  6. rst ("CallType") <> "N/A"
  7.     .MoveNext
  8.     Set rst = Nothing
  9. Loop
  10. End With
  11.  
  12. If Me.[CallType] <> "N/A" Then Msgbox "you must have an N/A value"
  13.  
  14. End Sub
this is onclose event of form(witch is Datasheetview)
FYI: I do have a DOA referrrence
Mar 14 '08 #1
2 1415
Stewart Ross
2,545 Expert Mod 2GB
Hi Trevor. There are a number of problems in your code extract, which is not going to run just yet. A skeleton that opens a table or query and checks for the value you are trying to match is listed below.
Expand|Select|Wrap|Line Numbers
  1. Dim rst as DAO.RecordSet
  2. Dim ValueFound as Boolean
  3. ValueFound = False
  4. set rst = CurrentDB.OpenRecordset("name of your query or table")
  5. Do While Not rst.EOF
  6.     ValueFound = rst![CallType] = "N/A"
  7.     rst.Movenext
  8. Loop
  9. rst.Close
  10. If ValueFound then
  11.     {do stuff}
  12. else
  13.     {do something else}
  14. endif
I guess when you say a textbox you mean a combo or a listbox. It is the recordsource for this you would need to open in the code above.

Personally, I'd use Access queries for this - which you can access using functions such as DLookup in code if you have to. The problem with taking a programmed approach is that all of the logic is hidden away from the users and maintainers of your application. Anyway, that's just my approach to it.

-Stewart
Mar 14 '08 #2
Hi Trevor. There are a number of problems in your code extract, which is not going to run just yet. A skeleton that opens a table or query and checks for the value you are trying to match is listed below.
Expand|Select|Wrap|Line Numbers
  1. Dim rst as DAO.RecordSet
  2. Dim ValueFound as Boolean
  3. ValueFound = False
  4. set rst = CurrentDB.OpenRecordset("name of your query or table")
  5. Do While Not rst.EOF
  6.     ValueFound = rst![CallType] = "N/A"
  7.     rst.Movenext
  8. Loop
  9. rst.Close
  10. If ValueFound then
  11.     {do stuff}
  12. else
  13.     {do something else}
  14. endif
I guess when you say a textbox you mean a combo or a listbox. It is the recordsource for this you would need to open in the code above.

Personally, I'd use Access queries for this - which you can access using functions such as DLookup in code if you have to. The problem with taking a programmed approach is that all of the logic is hidden away from the users and maintainers of your application. Anyway, that's just my approach to it.

-Stewart
Stewart, I'm thinking I went about this the wrong way , so here is what I am trying to do:
I have a form in Datasheet view(to have more controle over users. The datasheet is actualy a lookup table on a form, so that I can make check values before the lookup table itself is updated the field displayed on the form (in datasheetview) is [CallType] the form name is [form1], and I need to check to make sure 1 of the values is N/A , N/A count = 0 then mesgbox 1 of the values must be N/A, if N/A count = > 1 Then msgbox only 1 N/A value is required, please make the necessisary changes.
Mar 14 '08 #3

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

Similar topics

11
by: Jim | last post by:
Hi, I keep getting form results emailed to me that would indicate a form from my web site is getting submitted with all fields blank or empty, but my code should preventing users from proceeding...
0
by: Tim::.. | last post by:
Hi can someone please give me some help with this little problem I am having with the following loop ...:: CODE ::. < 'Load XM set xml = Server.CreateObject("Microsoft.XMLDOM" xml.async = fals...
5
by: rjames.clarke | last post by:
I have the following. $result=mysql_query($sql); $nrows=mysql_num_rows($result); for ($i=0;$i<$nrows;$i++) { $row_array=mysql_fetch_row($result); echo "<form name='testform'...
3
by: Gorlon the Impossible | last post by:
Hello. I am using Python 2.3.5 with IDLE 1.0.5 on a Windows98 PC. I have some programming experience but mostly I am still learning. I am having some trouble understanding the behaviour of a piece...
2
by: spidrw | last post by:
I have a system that lets users input service events (much like appointments at a Dr.'s office). Oftentimes a particular person will have 30 or 31 appointments in a month, as all events are...
2
by: javahelpneeded | last post by:
I am needing help writing a program in which every month of the year is enumerated. It needs to run so that the user can input a day of the year in the format mm/dd/yyyy and the output be the day...
6
by: subhashkumar | last post by:
Running data Append to a table Dear All, I need a help from this forum, I was developing a small tools for stock market. I get stuck when trying to save the running changes in a data field...
1
by: ebernedo | last post by:
Hey guys, I have two main questions First off (pictures are kind of blurry) I have this table http://i197.photobucket.com/albums/aa109/ebernedo/DiscTable.jpg And thats my database I use my...
5
by: Daten | last post by:
I have a loop that looks like this int i; for (i = 0; i < FriendsArray.Count; i++) { MessageBox.Show("Im in the loop " + key);
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.