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

Autokeys / setvalue macro problem

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.
Jul 7 '07 #1
8 2754
JConsulting
603 Expert 512MB
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?
Jul 7 '07 #2
ADezii
8,834 Expert 8TB
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:
Expand|Select|Wrap|Line Numbers
  1. Condition           Action    Applicable Object          Value
  2. Field1="Y"           SetValue           Field2                "Y"
  3. Field1="N"           SetValue           Field1              "Y"
  4. Field2="Y"           SetValue           Field3                "Y"
  5. Field2="N"           SetValue           Field2                "Y"
  6. Field3="Y"           SetValue           Field4                "Y"
  7. Field3="N"           SetValue           Field3                "Y"
  8. Field4="Y"         SetValue          Field5            "Y"
  9. Field4="N"           SetValue           Field4                "Y"
  10. etc.
Jul 7 '07 #3
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.
Jul 9 '07 #4
ADezii
8,834 Expert 8TB
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.
Jul 10 '07 #5
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.
Jul 10 '07 #6
ADezii
8,834 Expert 8TB
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:
  1. In the Action Column enter RunCode.
  2. For the Function Name Argument, enter fModifyFieldSettings().
  3. 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.
  4. Open Main Form and consecutively press the CTRL+1 Key combination.
  5. Let me know how you make out.
    Expand|Select|Wrap|Line Numbers
    1. Public Function fModifyFieldSettings()
    2. Dim fld1, fld2, fld3, fld4, fld5, fld6
    3.  
    4. Set fld1 = [Forms]![Main Form]![Field1]
    5. Set fld2 = [Forms]![Main Form]![Field2]
    6. Set fld3 = [Forms]![Main Form]![Field3]
    7. Set fld4 = [Forms]![Main Form]![Field4]
    8. Set fld5 = [Forms]![Main Form]![Field5]
    9.  
    10. If Nz(fld1.Value) <> "Y" Then
    11.   fld1.Value = "Y"
    12.     Exit Function
    13. End If
    14.  
    15. If Nz(fld1.Value) = "Y" And Nz(fld2.Value) <> "Y" Then
    16.     fld2.Value = "Y"
    17.       Exit Function
    18. End If
    19.  
    20. If Nz(fld1.Value) = "Y" And Nz(fld2.Value) = "Y" And _
    21.    Nz(fld3.Value) <> "Y" Then
    22.     fld3.Value = "Y"
    23.       Exit Function
    24. End If
    25.  
    26. If Nz(fld1.Value = "Y") And Nz(fld2.Value) = "Y" And _
    27.    Nz(fld3.Value) = "Y" And Nz(fld4.Value) <> "Y" Then
    28.     fld4.Value = "Y"
    29.       Exit Function
    30. End If
    31.  
    32. If Nz(fld1.Value) = "Y" And Nz(fld2.Value) = "Y" And _
    33.    Nz(fld3.Value) = "Y" And Nz(fld4.Value) = "Y" And Nz(fld5.Value) <> "Y" Then
    34.     fld5.Value = "Y"
    35.       Exit Function
    36. End If
    37. End Function
Jul 10 '07 #7
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.
Jul 11 '07 #8
ADezii
8,834 Expert 8TB
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.
Jul 11 '07 #9

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

Similar topics

4
by: dixie | last post by:
The Ctrl key is represented by a ^ in the autokeys macro. What is the Alt key symbol? dixie
0
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...
0
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...
3
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...
15
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...
6
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:...
4
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...
16
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...
3
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...
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: 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
jinu1996
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...
0
tracyyun
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...
0
agi2029
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,...

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.