|
-
Jul 1st, 2003, 03:50 AM
#1
Thread Starter
Addicted Member
Which is right? SOLVED!!!!!
To stop fields having blank values which is right?
blah blah on click
if
A) text6.value = false
B) text6.value = Null
C) text6.value = 0
then
Etc
A B or C?
or is there another?
NB must be done in this style, due to forms opening and closing.
Last edited by Bazzlad; Jul 1st, 2003 at 07:17 AM.
-
Jul 1st, 2003, 03:57 AM
#2
PowerPoster
Code:
if trim(Text1.Text) = "" then
Msgbox "text1 is empty"
else
'Do processing
end if
-
Jul 1st, 2003, 04:07 AM
#3
Thread Starter
Addicted Member
apparantly I:
Can't reference a property unless it has the focus
Nb using VBA, and the text box is hidden......
If Text6.Value = 0 Then
responce = MsgBox("Enter a Customer Name", vbOKOnly, "You messed up!")
Else: GoTo 10
10: blah
end if
that works, but only if i put my text boxes default value as 0..
which I don't want to do.
-
Jul 1st, 2003, 04:19 AM
#4
PowerPoster
VBA. U didnt mention this in the first post, or maybe I didnt pick it up .Sorry bud, no idea of it
-
Jul 1st, 2003, 04:23 AM
#5
Thread Starter
Addicted Member
thats why i'm stuck...it's like VB. but different
Lol, your code would have worked if my text wasn't hidden and taking its value from a combo box
help anyone?
-
Jul 1st, 2003, 04:52 AM
#6
I don't get your problem.
I used this code in VBA:
VB Code:
Private Sub UserForm_Click()
If TextBox1.Text = "" Then
MsgBox "TextBox is empty"
Else
MsgBox "TextBox is not empty"
End If
End Sub
I did set the TextBox1. visible and .enabled to False, whenever I click on the UserForm, it says "..is empty" (if the Textbox is empty!).
What'S your problem?
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Jul 1st, 2003, 04:59 AM
#7
Thread Starter
Addicted Member
"and you can't reference a property unless it has the focus"
Also, the hidden textbox is taking its value from a combo box..
txtbox.value = combobox.value
and for soem reason...it doesnt like it//
-
Jul 1st, 2003, 05:07 AM
#8
Thread Starter
Addicted Member
GRRRRRRRRRRR
**** it, here's my full code for that section
(and please don't shout about my goto's .....
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click
If Text6.Value = 0 Then
responce = MsgBox("Enter a Customer Name", vbOKOnly, "You messed up!")
Else: GoTo 10
10
If IMEI.Value = 0 Then
responce = MsgBox("Enter an IMEI Number", vbOKOnly, "You messed up!")
IMEI.SetFocus
Else: GoTo 20
20
If Make.Value = 0 Then
responce = MsgBox("Enter an Phone Make", vbOKOnly, "You messed up!")
Make.SetFocus
Else: GoTo 30
30
Dim stDocName As String
Dim stLinkCriteria As String
me.visible =false
stDocName = "frmrepair"
DoCmd.OpenForm stDocName, , , stLinkCriteria
stDocName = "frmrepair"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acNewRec
[Forms]![frmrepair]![Text14] = [Forms]![frmphone]![IMEI]
[Forms]![frmrepair]![Customer Name] = [Forms]![frmphone]![Text6]
[Forms]![frmrepair]![Check25] = [Forms]![frmphone]![Warranty]
End If
End If
End If
Exit_Command8_Click:
Exit Sub
Err_Command8_Click:
MsgBox Err.Description
Resume Exit_Command8_Click
End Sub
The problem I'm having is this...
If I put in a username but leave the IMEI out, the ******* thing still decides to hide my form and load the other, on the other form IMEI.value is required = error message and stuck.
Please bear in mind
text6 is invisible and reads from the combo box
addphonecn.combo
I can't see what's wrong....
-
Jul 1st, 2003, 05:08 AM
#9
how should a Textbox take something into .Value if it doesn'T have a .Value properiety?
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Jul 1st, 2003, 05:17 AM
#10
What the f***
VB Code:
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click
'What's Text6.Value, shouldn'T it be .Text?
If Text6.Value = 0 Then
responce = MsgBox("Enter a Customer Name", vbOKOnly, "You messed up!")
Else: GoTo 10
'If you come here, there is way way to go around "10" so forget the GoTo
10
'this part will only be checked if you failed on the first check!
If IMEI.Value = 0 Then
responce = MsgBox("Enter an IMEI Number", vbOKOnly, "You messed up!")
IMEI.SetFocus
Else: GoTo 20
'If you come here, there is way way to go around "20" so forget the GoTo
20
'this part will only be checked if you failed on the first two checks!
If Make.Value = 0 Then
responce = MsgBox("Enter an Phone Make", vbOKOnly, "You messed up!")
Make.SetFocus
Else: GoTo 30
'If you come here, there is way way to go around "30" so forget the GoTo
30
'this part will only be done if all checks above failed!
Dim stDocName As String
Dim stLinkCriteria As String
me.visible =false
stDocName = "frmrepair"
DoCmd.OpenForm stDocName, , , stLinkCriteria
stDocName = "frmrepair"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acNewRec
[Forms]![frmrepair]![Text14] = [Forms]![frmphone]![IMEI]
[Forms]![frmrepair]![Customer Name] = [Forms]![frmphone]![Text6]
[Forms]![frmrepair]![Check25] = [Forms]![frmphone]![Warranty]
End If
End If
End If
Exit_Command8_Click:
Exit Sub
Err_Command8_Click:
MsgBox Err.Description
Resume Exit_Command8_Click
End Sub
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Jul 1st, 2003, 05:18 AM
#11
Thread Starter
Addicted Member
It does. Doesn't it?
And if not, what bloody code do I use instead?
When I originally used .text I got that damn error message.
-
Jul 1st, 2003, 05:21 AM
#12
Sorry, you're right Textboxes have an .Value.
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Jul 1st, 2003, 05:22 AM
#13
Thread Starter
Addicted Member
'this part will only be done if all checks above failed!
thats the idea.
If the test is failed it means the text boxes have a value in them, thus not causing a conflict with the next form, which takes the values from this form and locks the boxes. Bear in mind they are required, so an empty, locked text box = me.screwed.
It's a weird one, and my coding isn't exactly, hmmm, generic, meaning there are a lot of **** ups in it!!
Any ideas?
-
Jul 1st, 2003, 05:30 AM
#14
Try Checking if .Value=""
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Jul 1st, 2003, 05:36 AM
#15
Thread Starter
Addicted Member
No dice :'(
If you know another way, even if the code is totally different, I'm willing to try,
All I need is for it to check the 3 textboxes for data (they MUST have data) then if they do, load the next form...
Thanx
-
Jul 1st, 2003, 05:37 AM
#16
This way it looks better (wihout those useless GoTo's
VB Code:
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click
If Text6.Value = ""Then
responce = MsgBox("Enter a Customer Name", vbOKOnly, "You messed up!")
Else
If IMEI.Value = "" Then
responce = MsgBox("Enter an IMEI Number", vbOKOnly, "You messed up!")
IMEI.SetFocus
Else
If Make.Value ="" Then
responce = MsgBox("Enter an Phone Make", vbOKOnly, "You messed up!")
Make.SetFocus
Else
Dim stDocName As String
Dim stLinkCriteria As String
me.visible =false
stDocName = "frmrepair"
DoCmd.OpenForm stDocName, , , stLinkCriteria
stDocName = "frmrepair"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acNewRec
[Forms]![frmrepair]![Text14] = [Forms]![frmphone]![IMEI]
[Forms]![frmrepair]![Customer Name] = [Forms]![frmphone]![Text6]
[Forms]![frmrepair]![Check25] = [Forms]![frmphone]![Warranty]
End If
End If
End If
Exit_Command8_Click:
Exit Sub
Err_Command8_Click:
MsgBox Err.Description
Resume Exit_Command8_Click
End Sub
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Jul 1st, 2003, 05:43 AM
#17
What'S happening when you use the check on .Value="", and what is the .Value (use a debug.print to check!)
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Jul 1st, 2003, 05:50 AM
#18
I checked the code (using te "" Check!) (except the part after the End If'S) in VBA, if any of the three Textboxes is Empty the Sub will be exited, if there is anything in there, the part after the End If'sd will be done!
See after my lunch break!
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Jul 1st, 2003, 05:52 AM
#19
Thread Starter
Addicted Member
this is ridiculous
with your code, it just opens the next form, but blank with the error of customer_name cannot be left empty.
Debug.print?
never used it!
-
Jul 1st, 2003, 06:01 AM
#20
Re: this is ridiculous
Originally posted by Bazzlad
...but blank with the error of customer_name cannot be left empty.
I don'T understand that part.
So "my" code worked for the first part?
Use "Debug.Print Var" to print the value of Var into the Direct Window (part of the IDE) .
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Jul 1st, 2003, 06:12 AM
#21
Thread Starter
Addicted Member
It opens form repair (blank) as it should
but the customer name and IMEI number are Both empty
that cant happen, as I cant, nor do I want to, put in those values manually still cant figure:
Debug.Print Var; Text6.Value?
wheres the value appear?
-
Jul 1st, 2003, 06:23 AM
#22
Correct Statement for Debug.Print
It will be printed onto the DirectWindow(I hope that'S the correct English name for it), if it is not visible in your VB-IDE you have to select it visible.
Looking at the code, you only try to handover two of the checked values (Customer_Name and IMEI), the third one checked was "make" but you try to hanover "Warranty".
So, you not getting any correct handing over from one form to the other.
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Jul 1st, 2003, 06:28 AM
#23
To handover from one Form to the other I use:
VB Code:
RecievingForm.Text6.Value = SendingForm.TextBox1.Value
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Jul 1st, 2003, 06:50 AM
#24
Thread Starter
Addicted Member
ahh yes, I want warranty handed over, but it does not have to have a value, in that instance 0 = fine.
I use MAKE.text on a different form later is it is needed,
can;t find VB-IDE, I am using VBA, that make any difference?
-
Jul 1st, 2003, 06:52 AM
#25
Thread Starter
Addicted Member
What I need to solve it is this...
I need to know what figure/number/name is used for an empty textbox value...
-
Jul 1st, 2003, 06:54 AM
#26
Thread Starter
Addicted Member
I think it's = false
So the problem lies in my multiple If statement...
is there a better way to make more than one if statement?
can I use select case?
Bazz
-
Jul 1st, 2003, 07:03 AM
#27
I ment VBA-IDE, the keyboardcommand to show the DirectWindow is CTRL-G.
The Check should be for =""
And the problem you discribed is more like a false handover of the values from one form to the other. Try this code:
VB Code:
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click
If Text6.Value = ""Then
responce = MsgBox("Enter a Customer Name", vbOKOnly, "You messed up!")
Else
If IMEI.Value = "" Then
responce = MsgBox("Enter an IMEI Number", vbOKOnly, "You messed up!")
IMEI.SetFocus
Else
If Make.Value ="" Then
responce = MsgBox("Enter an Phone Make", vbOKOnly, "You messed up!")
Make.SetFocus
Else
Dim stDocName As String
Dim stLinkCriteria As String
me.visible =false
stDocName = "frmrepair"
DoCmd.OpenForm stDocName, , , stLinkCriteria
stDocName = "frmrepair"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acNewRec
'I changed something here, not sure if you really need the "Forms." part.
Forms.frmrepair.Text14.Value = Forms.frmphone.IMEI.Value
Forms.frmrepair.Customer Name.Value = Forms.frmphone.Text6.Value
Forms.frmrepair.Check25.Value = Forms.frmphone.Warranty.Value
End If
End If
End If
Exit_Command8_Click:
Exit Sub
Err_Command8_Click:
MsgBox Err.Description
Resume Exit_Command8_Click
End Sub
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Jul 1st, 2003, 07:18 AM
#28
Thread Starter
Addicted Member
YEAH!
I figured it out!!!
Thanks a hell of a lot to opius who helped me loads!
This is the working code!!
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click
If Text6.Value = False Then
responce = MsgBox("Enter a Customer Name", vbOKOnly, "You messed up!")
Else
GoTo 10
Exit Sub
10
If IMEI.Value >= "" Then
GoTo 20
Else: responce = MsgBox("Enter an IMEI Number", vbOKOnly, "You messed up!")
Exit Sub
20
If Make.Value >= "" Then
GoTo 30
Else: responce = MsgBox("Enter an Phone Make", vbOKOnly, "You messed up!")
Exit Sub
30
Dim stDocName As String
Dim stLinkCriteria As String
Me.Visible = False
stDocName = "frmrepair"
DoCmd.OpenForm stDocName, , , stLinkCriteria
stDocName = "frmrepair"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acNewRec
[Forms]![frmrepair]![Text14] = [Forms]![frmphone]![IMEI]
[Forms]![frmrepair]![Customer Name] = [Forms]![frmphone]![Text6]
[Forms]![frmrepair]![Check25] = [Forms]![frmphone]![Warranty]
End If
End If
End If
Exit_Command8_Click:
Exit Sub
Err_Command8_Click:
MsgBox Err.Description
Resume Exit_Command8_Click
End Sub
-
Jul 1st, 2003, 07:24 AM
#29
Just curious, what MS-Product are you using?
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Jul 1st, 2003, 07:27 AM
#30
Thread Starter
Addicted Member
Access 2000...
I don't get why text6.value HAS to be .false
and the others HAVE to be >=
It makes no sense, but hey, it works 
Thanx again
-
Jul 1st, 2003, 07:39 AM
#31
Oh, Access, didn'T get that. That'S reason for the "false Handover", I did it in EXCEL.
I can'T tell the difference between FALSE and "", but the difference between = and >= is obvious. The first check (Terxt6) was if there is no input (if that statement is correct the sub will be exited after showing trhe messagebox). The other checks are the way around, that is if something has been set to those Textboxes the check is valid and you do your GoTo, only if the check fails the Messagebox comes up.
This way you get three messageboxes if all textboxes are empty, in my solution the first one would have thrown you out!
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Jul 1st, 2003, 07:48 AM
#32
Thread Starter
Addicted Member
3 message boxes???
No you don't!!
I used exit sub after each if, so if a messagebox shows, it exits automatically.
-
Jul 1st, 2003, 07:54 AM
#33
You're right, you do exit each time,
it's hard to read this jumping jack code
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Jul 1st, 2003, 08:06 AM
#34
Thread Starter
Addicted Member
yeah, its a little old skool BASIC he he...
my old teACHER would lamp me for using so many GOTOs..
in fact he'd lamp me for using any.....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|