Afternoon all. Am having some trouble I hope you can help with.
I have twelve fields in a table (Labelled 1 - 12). I have created an autokey/setvalue macro so that when I press CTRL1, field 1 is populated with a "Y". So far so good.
What I need to be able to do is press CTRL1 again and field 2 is populated with a "Y" (as long as field 1 has already been done) and on the next press field 3 etc.etc.
Thought it would be easy but it's giving me a real headache. Anyone got any ideas? Thanks.
8 2754
Afternoon all. Am having some trouble I hope you can help with.
I have twelve fields in a table (Labelled 1 - 12). I have created an autokey/setvalue macro so that when I press CTRL1, field 1 is populated with a "Y". So far so good.
What I need to be able to do is press CTRL1 again and field 2 is populated with a "Y" (as long as field 1 has already been done) and on the next press field 3 etc.etc.
Thought it would be easy but it's giving me a real headache. Anyone got any ideas? Thanks.
Sorry, can you possibly provide us a bit more info? What does the SetValue macro look like...and how are you vieweing your table to update it...through a form or directly in the table?
Afternoon all. Am having some trouble I hope you can help with.
I have twelve fields in a table (Labelled 1 - 12). I have created an autokey/setvalue macro so that when I press CTRL1, field 1 is populated with a "Y". So far so good.
What I need to be able to do is press CTRL1 again and field 2 is populated with a "Y" (as long as field 1 has already been done) and on the next press field 3 etc.etc.
Thought it would be easy but it's giving me a real headache. Anyone got any ideas? Thanks.
You can attempt to set multiple Conditions within your Macro, so that the value "Y" is written to the proper Field based on entries in prior Fields. The logic would be something similar to: - Condition Action Applicable Object Value
-
Field1="Y" SetValue Field2 "Y"
-
Field1="N" SetValue Field1 "Y"
-
Field2="Y" SetValue Field3 "Y"
-
Field2="N" SetValue Field2 "Y"
-
Field3="Y" SetValue Field4 "Y"
-
Field3="N" SetValue Field3 "Y"
-
Field4="Y" SetValue Field5 "Y"
-
Field4="N" SetValue Field4 "Y"
-
etc.
Sorry, can you possibly provide us a bit more info? What does the SetValue macro look like...and how are you vieweing your table to update it...through a form or directly in the table?
I'm viewing the table through a form. The SetValue macro looks like this:
Macro Name Action
^1 SetValue
Item : [Forms]![Main Form]![M1} (M1 being field 1)
Expression: "Y"
This works fine. So what I need it to do is: the next time I press CTRL1 it checks whether field 1 on the selected record has a Y in it. If it does then it updates field 2 and so on.
I tried putting another macro in the next row using the same name (^1) with a condition but it wouldn't allow it.
I hope this makes sense.
I'm viewing the table through a form. The SetValue macro looks like this:
Macro Name Action
^1 SetValue
Item : [Forms]![Main Form]![M1} (M1 being field 1)
Expression: "Y"
This works fine. So what I need it to do is: the next time I press CTRL1 it checks whether field 1 on the selected record has a Y in it. If it does then it updates field 2 and so on.
I tried putting another macro in the next row using the same name (^1) with a condition but it wouldn't allow it.
I hope this makes sense.
It does make sense and would be much easier to implement via code rather than multiple conditions within a Macro. You can also assign a Shortcut Key combination to launch the routine as you had previously requested. If you are interested, let me know and I'll work on iot.
It does make sense and would be much easier to implement via code rather than multiple conditions within a Macro. You can also assign a Shortcut Key combination to launch the routine as you had previously requested. If you are interested, let me know and I'll work on iot.
If you could that would be great. I know a small amount about code but this has got me stumped. My other alternative was to assign different keys to each field but that could get too confusing when entering the data.
Thanks for your help, much appreciated.
If you could that would be great. I know a small amount about code but this has got me stumped. My other alternative was to assign different keys to each field but that could get too confusing when entering the data.
Thanks for your help, much appreciated.
Maintain your AutoKeys Macro but with 2 small changes:- In the Action Column enter RunCode.
- For the Function Name Argument, enter fModifyFieldSettings().
- Copy and Paste the below listed Function to a Standard Code Module. It is only programmed for 5 Fields (Field1 to Field5), but can easily be expanded if you so desire.
- Open Main Form and consecutively press the CTRL+1 Key combination.
- Let me know how you make out.
- Public Function fModifyFieldSettings()
-
Dim fld1, fld2, fld3, fld4, fld5, fld6
-
-
Set fld1 = [Forms]![Main Form]![Field1]
-
Set fld2 = [Forms]![Main Form]![Field2]
-
Set fld3 = [Forms]![Main Form]![Field3]
-
Set fld4 = [Forms]![Main Form]![Field4]
-
Set fld5 = [Forms]![Main Form]![Field5]
-
-
If Nz(fld1.Value) <> "Y" Then
-
fld1.Value = "Y"
-
Exit Function
-
End If
-
-
If Nz(fld1.Value) = "Y" And Nz(fld2.Value) <> "Y" Then
-
fld2.Value = "Y"
-
Exit Function
-
End If
-
-
If Nz(fld1.Value) = "Y" And Nz(fld2.Value) = "Y" And _
-
Nz(fld3.Value) <> "Y" Then
-
fld3.Value = "Y"
-
Exit Function
-
End If
-
-
If Nz(fld1.Value = "Y") And Nz(fld2.Value) = "Y" And _
-
Nz(fld3.Value) = "Y" And Nz(fld4.Value) <> "Y" Then
-
fld4.Value = "Y"
-
Exit Function
-
End If
-
-
If Nz(fld1.Value) = "Y" And Nz(fld2.Value) = "Y" And _
-
Nz(fld3.Value) = "Y" And Nz(fld4.Value) = "Y" And Nz(fld5.Value) <> "Y" Then
-
fld5.Value = "Y"
-
Exit Function
-
End If
-
End Function
ADezii, that is genius my friend. Worked first time!
Thanks for your help with this. If I get stuck again I'll know who to call!
Cheers.
ADezii, that is genius my friend. Worked first time!
Thanks for your help with this. If I get stuck again I'll know who to call!
Cheers.
Always glad to help.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: dixie |
last post by:
The Ctrl key is represented by a ^ in the autokeys macro. What is the Alt
key symbol?
dixie
|
by: Jorge Gallardo |
last post by:
Hola a todos.
Me gustaria lanzar desde una macro comandos del tipo que se suelen poner en
los eventos de los formularios, si es que se
puede...
Lo que necesito hacer es el ejecutar el comando...
|
by: Jim Caddy |
last post by:
Hi all,
I have an Autokeys Macro that's all in a sudden not working in access 2000
when pressing the key combinations. Open up the database in Access 2002 and
the macro works, reopen the...
|
by: Laurie |
last post by:
Hi,
I need to be able to manipulate field values within a structure using
FieldInfo.GetValue and FieldInfo.SetValue, in VB.Nt 2003. The GetValue
is working fine and makes it really easy for me...
|
by: Charles Law |
last post by:
I have adapted the following code from the MSDN help for PropertyInfo
SetValue. In the original code, the structure MyStructure is defined as a
class MyProperty, and it works as expected. There is...
|
by: Mindy |
last post by:
Hey,
I am using SetValue to change the DataEntry property of a form to
"YES". But It doesn't work. No error messages, but the property didn't
change.Following is the what I am writing
SetValue:...
|
by: ApexData |
last post by:
Hello
1- What is the AutoExec Macro? Is it the same thing as AutoKeys Macro?
2- I'm looking to Control Keys equally on startup for my entire app. I
understand that
the AutoKeys Macro is the...
|
by: mddrains |
last post by:
I recently purchased a laptop with Windows XP. I installed Access 2000 and find that SendKeys does not work in my AutoKeys Macro. I get a message at the bottom of the screen when I close the Macro...
|
by: HenHouse |
last post by:
Looked everywhere for an answer for this, guys. I want to populate a control on a form with a text string using SetValue in a macro.
Here it is:
Item: forms!frmCargoList!Season
Under...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |