Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2008 > Visual Basic 2008 Essentials
|
Visual Basic 2008 Essentials If you are new to Visual Basic programming with version 2008, this is the place to start your questions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2008 Essentials 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 March 4th, 2009, 08:02 PM
Registered User
 
Join Date: Mar 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Question Need help, button to get next entry in database.

Hello all! I am new to vb, so this may seem like a very basic post. Or my coding may reflect my status as a vb rookie, however, I come to you hoping for some help.

I am having the following issues.
I am trying to complete a "next" button on a userform so that once clicked it will seek the next applicable entry in my database. However I am VERY new to the VB game still. The code I have is supposed to seek out the next applicable code from ONLY the visible cells. (As the page will already be filtered, unless you suggest putting it in this coding.) and then stop running and enter the found data into the corresponding userform objects. then when the button is pressed again, it is to run the code to get the next applicable data from the last found entry.and once all entries have been gone through, it is to display a message stating as such. however this code is having 2 seperate issues. ( I have stepped through, searched forums, tried and error'd, but still the same or more disastrous results.I am not posting this issue as a first resort, I am trying to learn this mostly on my own.) the 2 major issues are, 1) This code will go to the next item as long there are not more than 2 rows sperating them, otherwise it gives me the no further entries end script. And 2) It will not recognize the end of the filtered names and run the no further entries when i want it to. It simply skips down and fills the form in as blank entries. I would appreciate a little bit of explanation as to my issues, so that I can learn from this. Thank you in advance. The code is as follows....

Private Sub CommandButton7_Click()
Sheets("Segmentor").Select
Dim rng As Range, cell As Range
iName = UserForm23.ComboBox1.Value
Set rng = ActiveCell
For Each cell In rng
iBegin:
' check if row is visible - if so, get it
If ActiveCell.Offset(1, 0).EntireRow.Hidden = True Then
ActiveCell.Offset(1, 0).Select
GoTo iBegin:
Else
' process this row
If cell.Value = iName Then
ActiveCell.Offset(1, 0).Select
UserForm23.TextBox2.Value = ActiveCell.Offset(0, 1).Value
UserForm23.TextBox4.Value = ActiveCell.Offset(0, 5).Value
UserForm23.ComboBox2.Value = ActiveCell.Offset(0, 2).Value
UserForm23.ComboBox3.Value = ActiveCell.Offset(0, 3).Value
UserForm23.ComboBox4.Value = ActiveCell.Offset(0, 3).Value
Else
If Not cell.Value = iName Then
GoTo iEnd
Exit For
End If
End If
End If
Next
Exit Sub
iEnd:
MsgBox "No further entries found.", vbInformation + vbOKOnly, "Error"
End Sub


I also have another smaller, much less detailed question.
1) I have a combobox that is to display time increments in hour:min (ie; 12:00 AM, 3:00 PM), but it is showing in decimal form, is there code to format the textbox, such as .format(hh:mm), or .format = ("hh:mm") or something along those lines?"
 
Old March 4th, 2009, 08:10 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

mmm.. hello.. this is vba for excel? not VS 2008.. I'm right???

First tip: goto instructions are totally, totally forbidden! also a goto escaping a decisition structure is even more forbidden!

So. No database? just looping cells?
__________________
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.
================================================== =========
 
Old March 4th, 2009, 08:35 PM
Registered User
 
Join Date: Mar 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Arrow Thank you, can you point me in the proper direction with this...

Hello, thank you for your quick response.
1) even more forbidden than totally, totally?!? check. point taken. thank you.
2) yes for excel/ (2007 & 2003, needs to work in both.)
3) no, not a database, sorry for the mis-communication on my behalf. am learning that I haven't learned enough quite yet. ha. just a hidden sheet in an excel workbook.
4) can you point me towards the correct info i should be looking at to get this to work properly and not do anything else that is totally forbidden.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Reuse form for database entry kwng Pro VB Databases 0 April 30th, 2007 02:26 PM
Searching a database for an entry sconineuk VB.NET 2002/2003 Basics 6 March 24th, 2006 12:25 AM
Database Entry Problems gmoney060 Classic ASP Databases 4 November 9th, 2004 08:19 AM
Database entry from HTML forms gmoney060 Classic ASP Basics 4 March 31st, 2004 04:50 AM
Database Double Entry isg2000 Access ASP 1 June 13th, 2003 04:30 AM





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