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.
Printable View
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.
Code:if trim(Text1.Text) = "" then
Msgbox "text1 is empty"
else
'Do processing
end if
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.
VBA. U didnt mention this in the first post, or maybe I didnt pick it up:D .Sorry bud, no idea of it
thats why i'm stuck...it's like VB. but different :confused:
Lol, your code would have worked if my text wasn't hidden and taking its value from a combo box :o
help anyone?
I don't get your problem.
I used this code in VBA:
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!).VB Code:
Private Sub UserForm_Click() If TextBox1.Text = "" Then MsgBox "TextBox is empty" Else MsgBox "TextBox is not empty" End If End Sub
What'S your problem?
"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//
:mad:
**** 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....
how should a Textbox take something into .Value if it doesn'T have a .Value properiety?
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
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.
Sorry, you're right Textboxes have an .Value.
thats the idea.Quote:
'this part will only be done if all checks above failed!
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?
Try Checking if .Value=""
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
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
What'S happening when you use the check on .Value="", and what is the .Value (use a debug.print to check!)
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!
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!
:confused:
I don'T understand that part.Quote:
Originally posted by Bazzlad
...but blank with the error of customer_name cannot be left empty.
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) .
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?
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.VB Code:
Debug.Print Text6.Value
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.
To handover from one Form to the other I use:
VB Code:
RecievingForm.Text6.Value = SendingForm.TextBox1.Value
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?
What I need to solve it is this...
I need to know what figure/number/name is used for an empty textbox value...
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
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
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
Just curious, what MS-Product are you using?
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 :D
Thanx again:D
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!
3 message boxes???
No you don't!!
I used exit sub after each if, so if a messagebox shows, it exits automatically.:D
You're right, you do exit each time,
it's hard to read this jumping jack code
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.....