Please could anyone tell me what is wrong with this code.
Do I need anything else other than this for it to work, or is my code missing further info requirements. Presently getting no result in Ret1.text5
If Ret1.text4 = 100 Then Ret1.Text5 = Wrong
Thank you
Werner
27 4785
Hi, if you are trying to check that the text box contains the string 100, u need the quotation marks...
i.e. if textbox.Text = "100".
If you are trying to check if it is a number you will need to parse the string to a number. (in this case integer)
i.e. Integer.Parse(TextBox.Text)
note.. this is for VB.net
Also you would need stirng notation around te text you are trying to enter
Please could anyone tell me what is wrong with this code.
Do I need anything else other than this for it to work, or is my code missing further info requirements. Presently getting no result in Ret1.text5
If Ret1.text4 = 100 Then Ret1.Text5 = Wrong
Thank you
Werner
You never mentioned, what is your front-end and what it means for Ret1? - If Val(txtName1.Text) = 100 Then txtName2.Text = valSomeValue
This will be correct.
You never mentioned, what is your front-end and what it means for Ret1? - If Val(txtName1.Text) = 100 Then txtName2.Text = valSomeValue
This will be correct.
Hi, thanks it was just the "" that was omitted. It works perfectly now.
Thanks for the help.
Werner
One more question if you could maybe have a look for me. I have a excel book that is opened by a command button running this script. It gives me object error. All I want it to do it open the book (which it does no problem) and then run the if statement. Gives me the error when it gets to that part. This is VB6
Private Sub Command3_Click()
Set xlBook = GetObject("c:\miprice software\data\retail.xls")
' Display Microsoft Excel and the Worksheet
' window.
xlBook.Application.Visible = True
xlBook.Windows(1).Visible = True
If textbox4.Text < " 100" Then
'Copy text fields Part 1
Retail.Range("g5") = textbox4.Text
Else
'Copy text fields Part 2
Retail.Range("g5") = textbox5.Text
End If
End Sub
Thanks once again.
One more question if you could maybe have a look for me. I have a excel book that is opened by a command button running this script. It gives me object error. All I want it to do it open the book (which it does no problem) and then run the if statement. Gives me the error when it gets to that part. This is VB6
Private Sub Command3_Click()
Set xlBook = GetObject("c:\miprice software\data\retail.xls")
' Display Microsoft Excel and the Worksheet
' window.
xlBook.Application.Visible = True
xlBook.Windows(1).Visible = True
If textbox4.Text < " 100" Then
'Copy text fields Part 1
Retail.Range("g5") = textbox4.Text
Else
'Copy text fields Part 2
Retail.Range("g5") = textbox5.Text
End If
End Sub
Thanks once again.
If textbox4.Text < " 100" Then
are you sure that should be " <Space>100".
okay, If you go for that
then use
If Trim(textbox4.Text) = "100" Then
what is the error that you are getting?
Hey, I'm not too familiar with VB6, but i think that the statement - If textbox4.Text < " 100" Then
is the problem...
You are asking if a string is less than another string... which if you think about it, doesnt really make sense.
If you are trying to find if the number entered into the textbox4 is less than 400, then you need to parse the text as an integer or a double... in vb.net this would be - If Integer.Parse(textbox4.text) < 100 Then
That will check if the number entered into the text box is less than 100... is this what you wanted?
Hey, I'm not too familiar with VB6, but i think that the statement - If textbox4.Text < " 100" Then
is the problem...
You are asking if a string is less than another string... which if you think about it, doesnt really make sense.
If you are trying to find if the number entered into the textbox4 is less than 400, then you need to parse the text as an integer or a double... in vb.net this would be - If Integer.Parse(textbox4.text) < 100 Then
That will check if the number entered into the text box is less than 100... is this what you wanted?
Yes, I want it to read the value ot that textbox and if it is < than 100 to follow the rest of the statement. The bottom line is i am trying to get that result posted in a excel sheet. The error I am getting is "run time error" object required.
Yes, I want it to read the value ot that textbox and if it is < than 100 to follow the rest of the statement. The bottom line is i am trying to get that result posted in a excel sheet. The error I am getting is "run time error" object required.
I actually don't need to use the if statement as all i am trying to do is to get the textbox4 posted in excel. I can then in excel write a if statement which is easy.
I actually don't need to use the if statement as all i am trying to do is to get the textbox4 posted in excel. I can then in excel write a if statement which is easy.
It is difficult to get only in some piece of code. And you have to explain more.
It is difficult to get only in some piece of code. And you have to explain more.
Ok, will try.
The function requirement is simple, but the actual coding is what is the problem. The first part opens a specific Xls workbook - that runs no problem. The second part is trying to enter a figure form a textbox into the workbook. As I said I don't need to use specifically the if code if there is another wa, this just seemd the easiest way. Hope that makes more sense. Sorry for the hassle.
Here is the whole code:
Private Sub Command3_Click()
Set xlBook = GetObject("c:\miprice software\data\retail.xls")
' Display Microsoft Excel and the Worksheet
' window.
xlBook.Application.Visible = True
xlBook.Windows(1).Visible = True
If textbox4.Text < " 100" Then
'Copy text fields Part 1
Retail.Range("g5") = textbox4.Text
Else
'Copy text fields Part 2
Retail.Range("g5") = textbox4.Text
End If
End Sub
Ok, will try.
The function requirement is simple, but the actual coding is what is the problem. The first part opens a specific Xls workbook - that runs no problem. The second part is trying to enter a figure form a textbox into the workbook. As I said I don't need to use specifically the if code if there is another wa, this just seemd the easiest way. Hope that makes more sense. Sorry for the hassle.
Here is the whole code:
Private Sub Command3_Click()
Set xlBook = GetObject("c:\miprice software\data\retail.xls")
' Display Microsoft Excel and the Worksheet
' window.
xlBook.Application.Visible = True
xlBook.Windows(1).Visible = True
If textbox4.Text < " 100" Then
'Copy text fields Part 1
Retail.Range("g5") = textbox4.Text
Else
'Copy text fields Part 2
Retail.Range("g5") = textbox4.Text
End If
End Sub
When I debug it stops at
If textbox4.Text < " 100" Then
and then says : Object required.
When I debug it stops at
If textbox4.Text < " 100" Then
and then says : Object required.
do you know of a simple code that will take the value of textbox4 and post it into excel cell g5?
Ok, will try.
If textbox4.Text < " 100" Then
End If
End Sub
still cannot get this
If textbox4.Text < " 100" Then
why not this
If val(textbox4.Text) < 100 Then
still cannot get this
If textbox4.Text < " 100" Then
why not this
If val(textbox4.Text) < 100 Then
I have used the code like you have suggested, but still same object required error. :-<<
I have used the code like you have suggested, but still same object required error. :-<<
can you say which line is that object error?
can you say which line is that object error?
Highlights the first line : If Val(textbox4.Text) < 100 Then
Highlights the first line : If Val(textbox4.Text) < 100 Then
just check the textbox name is 'textbox4'
just check the textbox name is 'textbox4'
Damn that was wrong it is actually text4 not textbox4, but still same error! I am not sure if I should preceed that part of the code with maybe something like :
Dim text4 as Integer ???? - tried it,but then said invalid qualifier.
Damn that was wrong it is actually text4 not textbox4, but still same error! I am not sure if I should preceed that part of the code with maybe something like :
Dim text4 as Integer ???? - tried it,but then said invalid qualifier.
Already text4 is an textbox control then how can you declare it again for integer?
Already text4 is an textbox control then how can you declare it again for integer?
Pure shot in the dark! I am as you can see a TOTAL newbie at this, so just starting to learn all the bits and pieces.
Pure shot in the dark! I am as you can see a TOTAL newbie at this, so just starting to learn all the bits and pieces.
I think all the textbox business is probably somewhat incidental to the main issue, which is that (unless things work a lot differently to VB6) there is no object in your application called Retail. Most likely, you need to change Retail.Range("g5") to a proper reference to xlBook or one of the WorkSheet objects contained within it.
I am having a similar problem in my code. Should be simple, what am I missing? -
If Val(StandardizedAllocation.Text) = "HOUSE MEETINGS: " Then StandardizedAllocationSumm.Text = "Consult with direct care staff ongoing medical concerns and plan of care."
-
End If
-
- If Val(StandardizedAllocation.Text) = "HOUSE MEETINGS: " Then StandardizedAllocationSumm.Text = "Consult with direct care staff ongoing medical concerns and plan of care."
-
End If
-
Well, I don't know exacly what problem you are having. But I can see two fairly obvious problems with this code. - The purpose of the Val() function is to take a string, convert it, and return a number. So it doesn't make any sense to compare the result to "HOUSE MEETINGS: ".
- Since you've coded the IF on a single line, it doesn't require (or perhaps it would be more precise to say it doesn't allow) an End If. To demonstrate the difference, these two pieces of code do precisely the same thing...
- ' Single-line...
-
If A = 1 Then B = 3
-
-
' Multi-line...
-
If A = 1 Then
-
B = 3
-
End If
So, per you example, this is what I have now -
If StandardizedAllocation.Text = HOUSE MEETINGS: Then StandardizedAllocationSumm.Text = Consult with direct care staff ongoing medical concerns and plan of care.
-
I still don't get anything returned in the second text box.
Here is the error I am getting now: "You can't reference a property or method for a control unless the control has the focus."
Here is my exact code for picking from two choises. I only get this error on the first choice, but don't get anything in the text box with the second one. -
Private Sub StandardizedAllocation_AfterUpdate()
-
If StandardizedAllocation.Text = "HOUSE MEETINGS:" Then StandardizedAllocationSumm.Text = "Consult with direct care staff ongoing medical concerns and plan of care."
-
If StandardizedAllocation.Text = "MD Appt.Prep:" Then StandardizedAllocationSumm.Text = "Case file reviewed for pending medical appointment. Plan of care reviewed and updated."
-
-
End Sub
-
Got it working, another member helped me. Thanks
"You can't reference a property or method for a control unless the control has the focus."
You said you were using VB6. VB6 does not report this error. Unless I'm gravely mistaken, this is an MS Access message.
Anyway, glad to hear you got it working.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: dmiller23462 |
last post by:
Hey guys....
I put an error-handling in my page and have it posted at the complete
end of the code, see below(when people were putting in 's I was
getting the delimiter errors). Great, I...
|
by: abbylee26 |
last post by:
User enters account number
if another account number is needed
User clicks add account which creates another row
When validating when they hit submit I want to check to make sure they tell
us...
|
by: amywolfie |
last post by:
Hi All:
I would like to run a report based on criteria from 3 unbound combo
boxes located on a parameter form (combo boxes are: cboCuisine,
cboLocation, and cboRestaurant)
The present code...
|
by: DP |
last post by:
hi,
i have a films table and form. i have a txt field in teh form called
txtSearch , and i;ve created a query with all the film table fields in it.
how can i get the query to load up, wth the...
|
by: Paul |
last post by:
Hi I am using the HtmlInputFile control to upload a file from a client to a
server. I have a browse to find the file on the server but need to create
the path dynamically as to were it will go...
|
by: ljungers |
last post by:
Have Form-1 with 3 text boxes and 1 command button. With any of the 3 boxes filled out and button is clicked, a Macro is performed that Opens a Query that has a WHERE clause that uses the 3 test...
|
by: chimambo |
last post by:
Hi All,
I have a little problem. I am retrieving records from a table and I
want to update the records using checkboxes. I am able to display the
database record quite alright and I have created...
|
by: Gari |
last post by:
Hello,
I am trying to build a filter query with some AND and OR.
I have three text boxes and 5 check boxes. The checkboxes are linked via code to other textboxes for the purpose of the query.
...
|
by: chaosdl |
last post by:
Hello,
I am currently using Visual Basic 2005 express edition with a MS Access database. I have made a "Contacts" Form, where the user will be able to enter a members surname and press an OK...
|
by: metalheadstorm |
last post by:
OK i have two listboxes that are populated by data from a Access Db, its populated by a if statement sayin if the data is the same as todays date put it in list box1 and if its tomorrows date but...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |