Welcome to dbFreaks.com!
FAQFAQ   SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

how to move through records on a database.

 
Goto page Previous  1, 2, 3
   Database Help (Home) -> Visual Basic RSS
Related Topics:
SQL and VB- how do u count records - hi, i've got a table in a access file, and i want to display a number on a form, a total unmber of a record. e.g. i have a table with paper and i want to display the total number of and i want to do it as a click..

Filtering records using textbox on form - Can I use the value of a bound textbox on an open form, as a criteria in a query. If so what would be the correct code for the SQL. If not how can I hold the required value (number) that is selected by the user from a combo box at startup, so that I can..

I need help with some VB or SQL programming for a database. - I need some VB or SQL coding to finish up an access database program. I am trying to choose selected records from an access table based on certain criteria. Example: 2 records needed out of 4 total records and the code should choose the 2 records with.

Shared Database Connection? - I want to use an oracle odbc on my windows server for an I am writing for client The result is I don't want to install the oracle client to get sql*net on every i am running my the program on. What should..

Package & Deployment wizard: Update a database - Dear, I have developed a VB6.0 which uses an access database. I deployed this with the & from Visual Basic, and it works fine. Due to some new I had to add an extra column to..
Next:  lettera  
Author Message
user3614

External


Since: Jan 31, 2005
Posts: 30



(Msg. 31) Posted: Thu Feb 17, 2005 1:40 pm
Post subject: Re: Programming Style [Login to view extended thread Info.]
Archived from groups: comp>lang>basic>visual>database (more info?)

thanx. i will indent my code. when i copy and paste, the indentation gets
messed up.
i didnt know about the with thing, thanx for that.

i've done programming in java, and thats even harder.

thanx for all the help. i appreciate it.

dev Smile

"Randy Day" <ruthal.RemoveThis@sasktel.nex> wrote in message
news:1119k6fj9m76159@corp.supernews.com...
 > Devin Panchal wrote:
 >
  > > i clocked the delete button. its works well. this is waht i've got;
  > > Private Sub cmdDeleteRecord_Click()
  > > If Not rs.EOF Then
  > > rs.Delete
  > > MsgBox "You have deleted 1 record.", vbExclamation, "Database"
  > > rs.MoveFirst
  > > RefreshForm
  > > rs.Update
  > > End If
  > > End Sub
 >
 > Devin, I put this in as separate reply to let you
 > get those other changes made and understood.
 >
 > I wanted to make some suggestions about programming
 > style, especially indentation.
 >
 > You may have noticed I've sent you a few code snippets
 > where some lines were indented. Indenting lines within
 > a loop or IF statement is a commonly accepted (some might
 > say 'expected') means of debugging code.
 >
 > It's surprising how often a visual cue such as the
 > wrong indentation on a line will point out a coding
 > error. I've included two copies of your Delete code
 > below, both with errors introduced; see which one you
 > spot quicker!
 >
 > Private Sub cmdDeleteRecord_Click()
 > If Not rs.EOF Then
 > rs.Delete
 > MsgBox "You have deleted 1 record.", vbExclamation, "Database"
 > rs.MoveFirst
 > RefreshForm
 > rs.Update
 > End Sub
 >
 > Private Sub cmdDeleteRecord_Click()
 > If Not rs.EOF Then
 > rs.Delete
 > MsgBox "You have deleted 1 record.", vbExclamation, "Database"
 > rs.MoveFirst
 > RefreshForm
 > End If
 > rs.Update
 > End Sub
 >
 > It's normal to have multiple levels of indentation;
 > notice below how the 'hierarchy' of the lines
 > appears visually. Lines in the same loop appear at
 > the same level of indentation:
 >
 > if v = 7 then
 > for x = 1 to 9
 > w = w + 1
 > do while z < w
 > rs.addnew
 > rs.movelast
 > rs.fields.item("Total") = x
 > loop
 > w = w + x
 > next x
 > rs.update
 > end if
 >
 > In VB (and other languages) the TAB key is your
 > friend!
 >
 > **************************************************
 >
 > The other thing you might find useful is the
 > 'with' keyword. Here's your delete code again:
 >
 > Private Sub cmdDeleteRecord_Click()
 > With rs
 > If Not .EOF Then
 > .Delete
 > MsgBox "You have deleted 1 record.", vbExclamation, "Database"
 > .MoveFirst
 > RefreshForm
 > .Update
 > End If
 > End with
 > End Sub
 >
 > With a nice short recordset name like 'rs' it isn't
 > so obvious, but imagine the savings in keystrokes
 > if 'rs' was called 'rsMyRecordSetNumber1'.
 >
 > 'With' can be used with any object using the '.'
 > separator: textboxes, comboboxes, recordsets, etc.<!-- ~MESSAGE_AFTER~ -->

 >> Stay informed about: how to move through records on a database. 
Back to top
Login to vote
Robert Berman

External


Since: Feb 17, 2005
Posts: 2



(Msg. 32) Posted: Thu Feb 17, 2005 2:40 pm
Post subject: Re: Programming Style [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Devin,

There is an autoindenter tool available for VB. You can get it at this web
page. I suspect you will find it is worth its weight in
common currency,

<a style='text-decoration: underline;' href="http://www.oaltd.co.uk/Indenter/Default.htm" target="_blank">http://www.oaltd.co.uk/Indenter/Default.htm</a>

Good luck,

Robert Berman



"Devin Panchal" <d.panchal DeleteThis @ntlworld.com> wrote in message
news:Dw4Rd.843$Wz1.386@newsfe4-gui.ntli.net...
 > thanx. i will indent my code. when i copy and paste, the indentation gets
 > messed up.
 > i didnt know about the with thing, thanx for that.
 >
 > i've done programming in java, and thats even harder.
 >
 > thanx for all the help. i appreciate it.
 >
 > dev Smile
 >
 > "Randy Day" <ruthal DeleteThis @sasktel.nex> wrote in message
 > news:1119k6fj9m76159@corp.supernews.com...
  >> Devin Panchal wrote:
  >>
   >> > i clocked the delete button. its works well. this is waht i've got;
   >> > Private Sub cmdDeleteRecord_Click()
   >> > If Not rs.EOF Then
   >> > rs.Delete
   >> > MsgBox "You have deleted 1 record.", vbExclamation, "Database"
   >> > rs.MoveFirst
   >> > RefreshForm
   >> > rs.Update
   >> > End If
   >> > End Sub
  >>
  >> Devin, I put this in as separate reply to let you
  >> get those other changes made and understood.
  >>
  >> I wanted to make some suggestions about programming
  >> style, especially indentation.
  >>
  >> You may have noticed I've sent you a few code snippets
  >> where some lines were indented. Indenting lines within
  >> a loop or IF statement is a commonly accepted (some might
  >> say 'expected') means of debugging code.
  >>
  >> It's surprising how often a visual cue such as the
  >> wrong indentation on a line will point out a coding
  >> error. I've included two copies of your Delete code
  >> below, both with errors introduced; see which one you
  >> spot quicker!
  >>
  >> Private Sub cmdDeleteRecord_Click()
  >> If Not rs.EOF Then
  >> rs.Delete
  >> MsgBox "You have deleted 1 record.", vbExclamation, "Database"
  >> rs.MoveFirst
  >> RefreshForm
  >> rs.Update
  >> End Sub
  >>
  >> Private Sub cmdDeleteRecord_Click()
  >> If Not rs.EOF Then
  >> rs.Delete
  >> MsgBox "You have deleted 1 record.", vbExclamation, "Database"
  >> rs.MoveFirst
  >> RefreshForm
  >> End If
  >> rs.Update
  >> End Sub
  >>
  >> It's normal to have multiple levels of indentation;
  >> notice below how the 'hierarchy' of the lines
  >> appears visually. Lines in the same loop appear at
  >> the same level of indentation:
  >>
  >> if v = 7 then
  >> for x = 1 to 9
  >> w = w + 1
  >> do while z < w
  >> rs.addnew
  >> rs.movelast
  >> rs.fields.item("Total") = x
  >> loop
  >> w = w + x
  >> next x
  >> rs.update
  >> end if
  >>
  >> In VB (and other languages) the TAB key is your
  >> friend!
  >>
  >> **************************************************
  >>
  >> The other thing you might find useful is the
  >> 'with' keyword. Here's your delete code again:
  >>
  >> Private Sub cmdDeleteRecord_Click()
  >> With rs
  >> If Not .EOF Then
  >> .Delete
  >> MsgBox "You have deleted 1 record.", vbExclamation, "Database"
  >> .MoveFirst
  >> RefreshForm
  >> .Update
  >> End If
  >> End with
  >> End Sub
  >>
  >> With a nice short recordset name like 'rs' it isn't
  >> so obvious, but imagine the savings in keystrokes
  >> if 'rs' was called 'rsMyRecordSetNumber1'.
  >>
  >> 'With' can be used with any object using the '.'
  >> separator: textboxes, comboboxes, recordsets, etc.
 >
 ><!-- ~MESSAGE_AFTER~ -->

 >> Stay informed about: how to move through records on a database. 
Back to top
Login to vote
Display posts from previous:   
   Database Help (Home) -> Visual Basic All times are: Pacific Time (US & Canada) (change)
Goto page Previous  1, 2, 3
Page 3 of 3

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]