473,287 Members | 1,978 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,287 software developers and data experts.

Storing data from a specific field when clicking on another

44
Hello there!
I’m coping with this problem I haven’t been able to solve so far.
I have a subform, say sbfrm1. What I need is that whenever in sbfrm1 I click
any record within a specific field, say field2, Access could read the numerical value shown inside a string in the same record but in another field, say field1 and store this value in a variable called Var1.
For example. If I click the value shown in field2 record ID7 while field1 recordID 7 shows the string “ABC 125”I need the numerical value 125 to be stored in Var1.
I suppose an onclick event could be used but I haven’t the faintest idea on how I can get what I need.
Thank you in advance for any useful suggestions.
Oct 19 '18 #1

✓ answered by NeoPa

That sounds straightforward enough David, however your description doesn't make very clear what data you want from [Field1] if it isn't exactly in the format you've illustrated. Is it always in position #5 that the numeric data starts? Will there ever be non-numeric data after the numeric data starts? For now I'll assume there will always be the first space before the numeric data.

You also don't describe what Var1 is or what you expect do do with it. For simplicity here I'll assume it's a variable you've defined elsewhere in the code and has a scope that makes it accessible from the form's module.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Field2_Click()
  2.     Var1 = Val(Split(Me.Field1.Value, " ")(1))
  3. End Sub
This code would go in the Form's associated module. If you paste it into the module then [Field2]'s OnClick property will be set up for you automatically.

Good luck with your project :-)

9 1404
NeoPa
32,554 Expert Mod 16PB
That sounds straightforward enough David, however your description doesn't make very clear what data you want from [Field1] if it isn't exactly in the format you've illustrated. Is it always in position #5 that the numeric data starts? Will there ever be non-numeric data after the numeric data starts? For now I'll assume there will always be the first space before the numeric data.

You also don't describe what Var1 is or what you expect do do with it. For simplicity here I'll assume it's a variable you've defined elsewhere in the code and has a scope that makes it accessible from the form's module.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Field2_Click()
  2.     Var1 = Val(Split(Me.Field1.Value, " ")(1))
  3. End Sub
This code would go in the Form's associated module. If you paste it into the module then [Field2]'s OnClick property will be set up for you automatically.

Good luck with your project :-)
Oct 19 '18 #2
David57
44
Hello NeoPa,
Thank you very much for replying.
ABC 125 was just an example.
The data I need to retrieve from Field1 is always the numeric one located at the end of a string of 3 possible types: FHP 177 or Z/FHP 125 or RCC/FHP 35 (the numbers can vary but the strings are the real one).
As you can see there always 1 space before the numeric data and no non-numeric data after.
The result I'm trying to obtain, NeoPa, is changing the font color and size of all records (usually just a few) showing in Field1 the numeric value stored in Var1.
David
Oct 20 '18 #3
David57
44
Hello NeoPa,
Wonder if adding a new field, say FieldNo, for the numeric value only, could make things any easier.
It still remains, however, the problem of changing the size and color of the records containing in Field1 the value stored in Var1, becouse this is the final result I am aiming to.
David
Oct 20 '18 #4
David57
44
Hello NeoPa,
In the last line of my previous post please read:
"containing in FieldNo the value stored in Var1"
Sorry for the mistake.
David
Oct 20 '18 #5
NeoPa
32,554 Expert Mod 16PB
That sounds like quite a different question David. One gives you a value from a Control after you click on another Control, the other changes Control properties based on the same value, but not triggered by clicking.

I suggest you give up on this one as the question's been asked and answered, and ask a separate one which more closely matches what you want. Other than the basic logic of extracting the number from the string the answer will be very different from this one.
Oct 20 '18 #6
David57
44
Hello NeoPa,
Thank you for your concerning in my problem.
Let us suppose I add one more field, say FieldNo, for numeric data only, then I can summarize the problem as follows (please refer to my first post).
Whenever I click any record within Field2, I want the value shown in the same record but in FieldNo
to be stored in Var1 in order to change the font size and color of any record in sbfrm1 that in fieldNo shows the value stored in Var1.
As a matter of fact the above actions are triggered by clicking any record within Field2.
I don’t know if this problem can be solved. Creating Var1 and adding FieldNo are just my idea for trying out a possible solution but maybe this is not the best choice. Sorry for my poor English.
David
Oct 22 '18 #7
NeoPa
32,554 Expert Mod 16PB
Hi David.

I expect your English is the problem with your not understanding my last post very clearly. I will say it again for you, but more clearly.

Your new question needs to be posted in a completely separate thread. That means you need to start a new thread and ask your question fully (so include all the details) and clearly. You are welcome to post in link to this current thread from your new one, but this one isn't very easy to follow so I would suggest starting from scratch completely may well be a better option for you.

This current thread will then stay as it is with an answer to the question you originally asked (even though it wasn't the question you intended to ask).

I'll look out for your new thread.
Oct 22 '18 #8
David57
44
Hi NeoPa,
I fully understand the point, now. I'll ask a different question in a new tread.
Thank you for helping.
David
Oct 23 '18 #9
NeoPa
32,554 Expert Mod 16PB
Always glad to help David :-)
Oct 23 '18 #10

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

Similar topics

6
by: jochen scheire | last post by:
Is there a way I can calculate a field in a form based on another field in the same form. When clicking submit, both values should be posted to the next page. I want to be able to type in a value...
2
by: JP SIngh | last post by:
Hi All I am writing an ASP application that deals with the TV tapes and two of the fields is what I am having issues with I need to store the duration of the program i.e. DURATION field only...
0
by: Jason | last post by:
I have a primary form which is used to enter/edit data in a table named Test_Results. On this primary form there is a subform which displays site addresses. This subform is linked to the primary...
7
by: jballard | last post by:
Hello, I have a database set-up with a form and two subforms in it. I have one of the subforms (replacement parts) set-up where you can pick part numbers from a drop down box and also pick a...
1
by: meganrobertson22 | last post by:
hi everybody- what is the best way to add data from one form to another? i have 2 tables: person and contract. here are some of the fields. table: person personid (autonumber and primary...
5
by: hfk0 | last post by:
Hi, I'm new to ASP.net, SQL Server and visual studio.net, and I'm having problem inserting and storing data from a web form to a SQL database. I created a simple ASP.NET web form, a simple SQL...
3
by: mathewgk80 | last post by:
Hello, I would like to know how to pass values of a gridview to another page when clicking on the link field in a gridview. Please help me. regards, Mathew
3
by: mckbill | last post by:
Is there a way I can direct the cursor to a specific field (variable) in a form by typing the field name while in form view? I have a form with many fields, and it would be nice if there were...
6
by: Randoz | last post by:
I have a simple data base with items that need to be worked on. Each record has a unique number assigned as a priority. The numbers are 1-100 for example, in the order that they are to be worked on....
8
by: billef32 | last post by:
I've made a database for my contacts. On the top of my main form (names) I put a combobox where the row source is : SELECT . , . , . FROM ORDER BY ; that will show me a list of ID name...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
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...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
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...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
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...
0
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.