473,397 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

How to give a value to a TextBox depending its row in a subform?

Hi everybody

I'm having troubles to give a value to a TextBox(called TextUM),according its row position in a subform.

The things is that i have i Subform called(SubFormModel3 - Zone1) and when i get into Design View i see 5 different TextBoxes (TextUM,TextUC, TextTrolley, TextUnite, Designation) and 1 Combobox.

When i enter to the DataSheet View everything is perfect, I see my 40 items(each one on a different row) and from one side i see 40 rows(each one with its own combobox option) and I want that depending on the choice (UM, UC, Trolley, Unite) of the user in every combobox, my variable (Uresult)is displayed in the proper TextBox in the row where the choice was made.

Just to clarify, i store the result of the combobox in a variable(called MeasureUnit) and the number of the row of the combobox selected(called PositionRow)


Public Sub Combobox_Click()

Expand|Select|Wrap|Line Numbers
  1. Dim PositionRow as Integer
  2. Dim MeasureUnit as String
  3. Dim Uresult as Double 
  4.  
  5.     If (MeasureUnit = "UM") Then
  6.        UMValue = ((QteComposants(PositionRow) / 1000) / UM(PositionRow))           ' No important
  7.  
  8.        TextUM.Value(PositionRow)= UMValue  <---- Problem
  9.     End if
  10.  
It drops me the error 13, type mismatch

Any help?
Oct 14 '15 #1
4 910
hvsummer
215 128KB
well, Orchaval, you use it wrong way.
if textUM is textbox, then you don't need to set textUM.value* = variable
just
Expand|Select|Wrap|Line Numbers
  1. Public Sub Combobox_Click()
  2. If (MeasureUnit = "UM") Then
  3. me.TextUM = ((QteComposants(PositionRow) / 1000) / UM(PositionRow))
  4. if me.dirty then me.dirty = false '(no need end if for this code... ==)
  5. end if
  6. end sub
but I suggest you create a seperate button and add this code (needsome tweak) into that button (name: save record)
Oct 14 '15 #2
Thank you for your response hvsummer. The problem that happens when I do that is that the result is copied in the other rows from the same Textbox (TextUM), and I want just to be copied in the row in which it was chosen.

Oct 14 '15 #3
hvsummer
215 128KB
@orchaval: can you make it more detail ?
and give some more code (rowsource, control source) of the relative textbox or combobox.
the part "the result is copied in the other rows from the same Textbox (TextUM), and I want just to be copied in the row in which it was chosen." is not clear to understand.
Oct 15 '15 #4
jforbes
1,107 Expert 1GB
First, I don't understand this:
Expand|Select|Wrap|Line Numbers
  1.        TextUM.Value(PositionRow)= UMValue  <---- Problem
I could be wrong, I don't think you can reference items like this. You can in .Net, sort of, but this would be a new one for me in Access.
Second, is TextUM a Bound or Unbound TextBox? And is this on a Continous Form? You won't be able to do what you want with Unbound Controls on a Continuos Form. Even though Access creates multiple instances of the Control on the Screen, they all share one set of properties. So, with an Unbound Control on a Continuous Form, if you change the value of one, it changes for all of the controls, regardless of what record they are on.
Oct 15 '15 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: John Michael | last post by:
I have a form that has a subform that has a subform. The subform loads a record based on a combo lookup box in the main form. I'm trying to set a value in the subform based on a value in a...
3
by: ton | last post by:
How can I in VB.NET set the width of a label or textbox depending on the length of the string and/or the font size. In my control I'm showing a textbox in a tablecell, which is added to a table...
3
by: luanhoxung | last post by:
Hi all !! i have met trouble with referring textbox of subform in VBA i know i can do as: forms!mainform.subform.textbox but i want do it in shorter path. any suggestion about using variable ?...
1
by: mattloflin | last post by:
Hey guys Probably an easy question but I can't get it to click: I have a form (frmSearch) that has a subform (frmDatabase) the frmSearch has textboxes that limit the frmDatabase off of that...
0
by: skips84s | last post by:
I have a parent form with four tabbed subforms. On subform x, selecting a value from a combo box should update a few controls on this subform, as well as a control on subform y, all done using...
0
by: MissE | last post by:
Hello Afternoon! I've been trying to work out whats going wrong with my function for the last 2 days. I give up... I have a main form (Infinity) with a command button which pops up a subform...
1
by: Dawit abrham | last post by:
I have a datagridview that has a dropdownlist and textbox. I want to assign a value to a textbox depending on the selected value of the dropdownlist. But I try this getting the error "Object...
2
by: lociteck | last post by:
Hello, How can i give an error depending on the array input? This is my code using System; class MainClass { public static void Main (string args) {
1
by: noorulain | last post by:
i want to pass the value of text box from a subform "concession" to a main form "student_detail" i am using the format forms!mainform name!subform name!ftextboxname.value to assign the textbox...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.