PDA

View Full Version : userform loading probs


Jimsta
02-11-2004, 09:31 PM
As mentioned before I've now modified it to use user forms ( makes it so much easier to interact with !! ). My user screen ( referenced as UserMenu in the project explorer) consists of three options that can be selected, one which is Existing user.

If Existing User is clicked, what happens is the login screen (referenced by UserLogin) appears for the existing user to login to the library database. The login screen consists of two textfields to enter name and password in as well as a button to click to login(called login).


Upon typing the username and password, what the coding does is it searches through the columns of the excel worksheet you opened up the VBEDitor through to validate the information.
If the details are correct, the search engine screen pops up and hence u can search from there.

Now the problem is that when i click the "login" button, the search engine userform won't pop up . My concern is that I think i might not be opening up the worksheet properly( that is The worksheet i launched VBEDitor from) and referencing the methods appropriately. Am I right or is there something Ive missed out on :confused: :confused:

Ive only attached the code for the UserLogin controls for analysing (since they won't let me upload xls file extensions
)

DNAunion2000
02-11-2004, 11:36 PM
Here are a few things.

1) A piece of advice: you should use meaningful variable names. If you are using an integer to loop through the rows of a worksheet, why not call the variable intRows or some other similar, meaningful name, instead of the vague and meaningless y. Same goes for having a variable to reference a workbook named just x, and one for a searchengine named just i.

2) Your syntax for a For loop is wrong. Instead of:

For y = 2 To y = 90

it should be:

For y = 2 To 90


3) ThisWorkbook is a property, not a class (object). That is, you can’t create a ThisWorkbook variable: the code should be:

Dim x As Workbook

instead of:

Dim x As ThisWorkbook

Jimsta
02-12-2004, 02:56 AM
Thanks for your advice :) I will take that into mind and let you know how it goes

DNAunion2000
02-12-2004, 08:13 PM
One thing you might want to try is "incremental programming". Instead of writing the whole function at one time, doing everything you want it to do, and then having several possible problem areas to contend with if it doesn't work right, you could stop coding as soon as the code performs one thing and "complie". Once you get that one part to work, move on to adding the second thing and compile again - keep making changes and compiling until you get that much to work. Continue doing this incremental process until you finally have the full functionality.

Another tip is to always try the simplest example you can think of when you are trying something new. If you aren't sure how to work with worksheets, for example, think of the simplest thing you can do with a worksheet and try doing just that.

Jimsta
02-13-2004, 09:54 AM
DANUnion 2000 finally got it working :D . I didn't declare a workbook object, what I did instead in my commandbutton 1 method was that i activated the sheet in my workbook using this line

"Workbooks("Book2.xls").Worksheets("Sheet1").Activate"

I specified it in this way so that it would focus on the workbook i was doing the VBCOde in ( in this case its book2) because i thought i was being too vague in my past specifications and just to be sure, I made absolute path references.

I also found that eliminating anything ending with ".Values=Null" and enclosed in a NOT made the program work as well :confused: (you might have seen them in my "if Then Else" statements, included as part of the conditions). I have no idea why this is the case though so perhaps you could shed some light on the issue.

Thanks by the way with the suggestive approaches to prorgramming. They really helped me make it easier to fix up and debug the problems with my login code. :)

Ive attached the new code for my UserLogin form if you want to check it out as well and see what you think. Cheers