Currently in my database, I have 4 buttons that update a table with some if then else and select case statements in each button. Well can I combine those to push one button and it will do all 4 buttons?
Currently in my database, I have 4 buttons that update a table with some if then else and select case statements in each button. Well can I combine those to push one button and it will do all 4 buttons?
Last edited by ncurran217; 02-17-2012 at 01:28 PM. Reason: Solved
Depends on the code. Post the code or attach the workbook
Hope that helps.
RoyUK
--------
For Excel Tips & Solutions, free examples and tutorials why not check out my web site
Free DataBaseForm example
This is one of the buttons (all four are the same except the select case statments and if then else statements):
Please Login or Register to view this content.
Last edited by ncurran217; 02-15-2012 at 03:00 PM.
Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
Ok I actually tried looking to do that but must have read over it, so I posted my code because you asked for it.
Well I tried to combine code, but does it seem to be wanting to do the second part of it with the [mycategory2]
Let me know if this helps on what I am trying to do.Please Login or Register to view this content.
What does this mean? Working or not working?but does it seem to be wanting to do the second part of it with the [mycategory2]
In looking at your code you have not defined category1 nor category2. You have category defined as a string so if it is not working that may be part of the issue.
Alan
Alan עַם יִשְׂרָאֵל חַי
Change an Ugly Report with Power Query
Database Normalization
Complete Guide to Power Query
Man's Mind Stretched to New Dimensions Never Returns to Its Original Form
The second group of If Then Else statements that has this in it:
Please Login or Register to view this content.
This is where I thought I would be defining it on which column to edit.
Please Login or Register to view this content.
Last edited by ncurran217; 02-15-2012 at 05:18 PM.
Your Dim statements defines your strings, variants, etc.
So this:
Dim mycategory As String
would turn into
Dim mycategory1 As String
Dim mycategory2 As String
??
Yes. Otherwise, Access doesn't know what they are and how to handle them.
Ok I did that, which is what I figured, but then when I click the button the debug comes up with this highlighted in the screenshot below:
screenshot.jpg
Any message? Have you tried stepping through the code (use the F8) key.
Look at this video. He will show you how to step through the code to see what is causing the error.
http://www.datapigtechnologies.com/f...vbadoloop.html
Alan
Well it wont let me step into the file. But when I go into debug mode after it comes up with the error I can hover over the Highlighted part and it shows it as NULL. Well I believe that is because it is a different column I need to edit. So how do I have a loop finish with the first column then loop through the file for the second column?
You know that individually each loop works. Take the first loop and complete it. Now at the end of the first loop insert the second loop and complete it. I can't see why this would not work for you. Alternatively, you could put each loop in a module and call them sequentially in the same code for the button. This is untested on my behalf but seems to make sense.
This is what I put, but seems to only do the first loop as the second loop edits the second column and nothing ends up in the second column. Unless I have the loops coded wrong, but it seems to do the first one but skips the second one!
Sorry new to coding and access, as you probably have seen, because you have helped me on various other things and really appreciate the help a lot!
Please Login or Register to view this content.
Well I think I have figured it out. I changed this:
To this:Please Login or Register to view this content.
I added the myset.MoveFirst after the Loop so when it finished it would move back to the first record and then start the second loop.Please Login or Register to view this content.
Excellent. Thanks for the feedback. I haven't done much with loops so this was a bit of learning experience for me also when adding the second loop.
Alan
im glad we worked it out and able to both learn something at the same time. Ill be adding two more to it so I will let you know how it goes!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks