473,405 Members | 2,262 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,405 software developers and data experts.

Form data not going to correct date tab

When the user enters a date in the date field (txtbox) the data seems to be going to only one date tab (current month). I need the data to go into the correct month tab. another words if the data being input is from 3/1/2010 i need it to go to worksheet named MAR2010. If the data is from 1/1/2010 I need it to go to worksheet named JAN2010. any ideas?
Jul 31 '10 #1
15 2028
Guido Geurs
767 Expert 512MB
Split the month from the text with:

Expand|Select|Wrap|Line Numbers
  1. Month = Left(TextBox1.Text, InStr(TextBox1.Text, "/") - 1)
Set the sheet name with:

Expand|Select|Wrap|Line Numbers
  1.       Select Case Month
  2.       Case "1"
  3.          SheetName = "JAN2010"
  4.       Case "2"
  5.          SheetName = "FEB2010"
  6.       Case "3"
  7.          SheetName = "MAR2010"
  8. ....
  9. ....
  10.       End Select
Send the data to that sheet (= SheetName)

Like this=

Expand|Select|Wrap|Line Numbers
  1. Private Sub CommandButton1_Click()
  2. Dim Month As String
  3. Dim SheetName As String
  4.    If IsDate(TextBox1.Text) Then
  5.       Month = Left(TextBox1.Text, InStr(TextBox1.Text, "/") - 1)
  6.       Select Case Month
  7.       Case "1"
  8.          SheetName = "JAN2010"
  9.       Case "2"
  10.          SheetName = "FEB2010"
  11.       Case "3"
  12.          SheetName = "MAR2010"
  13.       End Select
  14.       Worksheets(SheetName).Range("A1").Value = TextBox1.Text
  15.    Else
  16.       MsgBox "Enter a date"
  17.    End If
  18. End Sub
Jul 31 '10 #2
@ggeu

I noticed that you are using range("A1") but all my data gets added to a new row each time the user hits the enter key onb the user form. u have seen my project. how would i get to work fo me? same thing for the Printing a receipt problem. you are using a set cell. but if the client the user is looking for is in 151 how will that work?
Jul 31 '10 #3
sorry GGeu - not working ..... probably me.
Jul 31 '10 #4
Guido Geurs
767 Expert 512MB
Is this the same project as "printing a receipt from excel" ?
Please, attach an example of Your project in BYTES so we can help You based on the real problem and simulate the errors so we can find a solution for it!
Aug 1 '10 #5
ok GGEU, here it is again, I was told it was too busy and had to remove a few things. the things I was told to work on are the following:
1) i need any data that is entered into the form to go into the correct worksheet tab (i.e. if the date entered into the txtscheddate field is 1/1/2010 it will go into worksheet JAN2010.

2). I need a way that the user can print out a receipt. no matter who she is looking for. If the receipt is from Jan2010 and the user is liz martin or if the receipt was from yesterday and the user was kate blanchard. (this is a tough one).

3). My search code seems to be only searching in the worksheet of Jan2010 and not all of them, plus it only brings up the first occurrence of said said. I need it to bring up all occurrences for all twelve months.

I have added the zip file so you can take a look at it and tell me what you think. Oh waiti there is one more item. when the user first opens the userform and starts to type in data when she gets to the amount fields and presses' the CTRL & TAB button to get to the totmaterial txtbox it sometimes does not work. any ides why that is.

By the way if I have not thanked you before in the past Let express my deepest gratitude to you and everybody on this site. I have been to mr. excel and wopr.com and they seem as if they don't care about us newbies trying to make it inb the vba world. so thank yo very much.
Aug 2 '10 #6
Guido Geurs
767 Expert 512MB
Attached is what I have so far.
I don't think we can use CTRL+TAB to jump to Total because it enters a TAB in the starting textbox or in the end textbox.
So I have changed it to SHIFT+TAB and it's working.

I have added a Menu + button to start the Add form.

Next is the search and print code.
Attached Files
File Type: zip Form data not going to correct date tab_v3.zip (63.4 KB, 74 views)
Aug 3 '10 #7
Guido Geurs
767 Expert 512MB
I have been thinking about the problem "search" and have the next observations:

- If we want to search on the name of a client, these name must be the same in each data of that client.
What it means: if a user must enter the name by TYPING than he will enter "k. blanchard" or "kate b." or "kate blancharde" or ... for "kate blanchard" and the search will never find all the data.

- So we have to standard the names of the clients!
This is done by using a list on a sheet "Clients".

- This sheet has a lot of advantages !!

- This list can also be used for other things like: placing a listbox on the Add form in which the user can select directly the clients name and data of this client will automatically be filled in the form.

- Also in the "search" form we place this listbox so the user will search on the right name! and see all the data.

- The search will be centralized in an "Search" sheet where all data of this client will dis-plied.

- The user will select the data he needs to make a report and send this information to a special layout for printing.

I have attached the last state of the project.
Please give me comment if this is not what You want !!

PS:
Here is some advice on projects like this (it will shorten the development time and facilitate your work):

- Always make an Analise of the project.
Which means: consult the users on what they want: to do, to see, how work with, ... the data.
Because a programmer has his own ideas how a program can look like with fancy things but it is not always what the user wants.

- Study the ergonomic of the program: what must the user see at first, what is information on the screen (titles of textboxes not so big and data good visible)

- if possible, automate the work of the user like: dropdownlist (advantage= fast and correct data), get data from elsewhere, ...

- On the programming self:

Use clear explaining names (use a standard code) for different things like (I use this for fast and easy reading of the code):

Variables: clear description (All caption) = ROWIDX, USERNAME,...

Elements on the form: type (caption) description = CMDopen, TXTdate, ...

Name of function: verb_element underscore what= Open_File,...

Use for For...Next counter a description in stead of i, j, k like:
for ROWIDX=1 to 10
Because in more nested loops it's difficult to keep track of the different indexes used and which you must use in a code like cells(i,j) ?? cells(k,i) ?? better: cells(ROWIDX, COLIDX)

Add comment (not to much) to the code so You (or someone else) can reed it faster and understand the logic of it.
It will even help You if you have to change or adapt the code after a while.

Add indents in blocks of code like for...next, select case, if ...then, ...(you can detect faster if an "End..." is missing because VB gives sometimes an error like "with without END with" while there is a "For...next" without "Next" in it !!!)

I have not yet changed the names in attached project because I want first Your opinion on these suggestions !!!
Attached Files
File Type: zip Form data not going to correct date tab_v5.zip (71.7 KB, 61 views)
Aug 4 '10 #8
that lloks cool and the advice is great, both things I would have not thought of although I been informed to indent my code by my teacher. I like the calendar touch and adding a client list. SO every time the user adds a client in the txtboxes if they click add clients it goes to the client list and can be recalled at any time. oool. All the other entries in when you hit enter though do not go anywhere. Did I do something wrong on my enter command button?

P.s.
I just hope and pray that someday I'm as good as you are at this. How long have you been doing VBA? I'm reading up using Microsoft Visual Basic.net Reloaded. It teaches the basics as well as Visual basic 6. Is there any other book out there that you can recommend me to study/read to become better accomplished at this.
Aug 4 '10 #9
Guido Geurs
767 Expert 512MB
Your "ENTER" code was going nowhere!

Set ws = Worksheets(Format(Date, "MMMYYYY"))
irow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row

You must first define to which sheet and then to the first empty ROW.

like:

Define which sheet=
Expand|Select|Wrap|Line Numbers
  1.       Select Case MONTH
  2.       Case 1: WSNAME = "JAN2010"
  3.       Case 2: WSNAME = "FEB2010"
  4.       ....
  5.  
Activate it and go to the first empty row=
Expand|Select|Wrap|Line Numbers
  1.             WS.Activate
  2.             WS.Range("A1").End(xlDown).Offset(1, 0).Activate
PS:

I have changed the code for that part because it gives an error if there is no data entered yet or there is only 1 row entered.
So it must start at A1 and be:
Expand|Select|Wrap|Line Numbers
  1.          If WS.Name = WSNAME Then
  2.             WS.Activate
  3.             WS.Range("A1").End(xlDown).Offset(1, 0).Activate
  4.             With ActiveCell
  5.                .Value = txtpo
  6.                .Offset(0, 1) = txtname1
You see I also have still to learn a lot of things although I have started programming in 1975 (on a Texas TI94 with 12Kb RAM ) as a hobby but never have done it as a profession.
Although my jobs I have done were mostly with computers.

A good website with tutorials is:
http://www.theopensourcery.com/ostutor.htm#vba
with:
- Intro into Visual Basic
- The outline of the VB development Interface
- ...
http://www.vb6.us/guides/visual-basic-6-beginners-guide
with:
- Beginner Guide
- Controls Guide
- Database Guide
http://www.vbtutor.net/vbtutor.html
with:
- Introduction to Visual Basic 6
- Building VB Applications
- ...

Also You can Google for: "Ebook VB6 tutorial PDF"

The best thing to learn a programming language is always the practical way be solving real (industrial ) problems and also learning from other program codes.

But now back to our project=

- Must the name of the client be split into First and Last name ?
It gives us more programming (concatenate it for placing it in the listbox and splitting it again for searching it in the sheet) while maybe nobody is asking it for being splitted !

- Suggestions: always use the same name (or abbreviation of it) in the sheet, form, commands, ...( NOT OK: "First Name" = txtname1, ...)
Now we know its the same but after some months (and other projects) we (or someone else) will have to unravel the code before he understands the logic in the code.

- Also : use the names that the user of the program will us!

- Examine the data that must be entered: how long must the TEXTBOX be for a clear view of the data.

- Ask the user what the best layout is.(maybe for the ENTER form there is no need of a header with the name of the Firm, only on the reports and the printouts ??)

These are all points who must have an answer in the analysis.
Aug 5 '10 #10
Point 1). I'm not sure if the name has to be split, but what happens if we only have a last name of the client.? Thats just the example we were given.

great point on the suggestions!!! I know K.I.S.S. (keep it simple stupid) right! I get it.

on the textbox length, why does it have to be so long, cant we just word wrap it and scroll down?

There is no real need for the header on the form, It's just something I added. you can take that away.

Also thank you for the suggestions, on the education side. It really is appreciated. I want to get to know this stuff so bad.
Aug 6 '10 #11
Guido Geurs
767 Expert 512MB
Attached is an Excel with Search and Report.
Click in the menu on "Add Data" to open the form.
Select in the list of clients a name.
Click on [Search]
Click on [Close]
In the "search" sheet are all the found records.
Click in a cell of the line you want a report of.
Click in the menu on "Sheet Report" or "Form report" to view the data in the report.
The reports have only a few fields: it's up to you to define the final layout of it.

Ps: You can also make a report by selecting a cell in a row on a data sheet (like "JAN2010",...) and click in the menu on "Report..."


I hope this will help you on Your project.
If You still have some problems, please let me know.
Attached Files
File Type: zip Form data not going to correct date tab_v2.1.zip (87.2 KB, 64 views)
Aug 8 '10 #12
I do have a couple questions if that is ok? Sorry I was on vacation but I'm back now and it looks pretty good. My questions are when the user accidentally types anything inside the COMBBclients it wants me to debug it (error), also the tab's seem to be all over the place. every time I try to correct them it goes right back to the way you have it is there something I'm missing? Last thing what are the macro commands to bring up the recoprt form and can I add on to it like what the job was and cost? thank you my friend.
Aug 14 '10 #13
Ok I was able to figure out how you added the items in the report form, pretty neat. I still have not been able to figure out the tab problem. also does the clients info have to be in the client spreedsheet in order to be printed on the report form. next week is turn in day. thanks again.
Aug 15 '10 #14
Guido Geurs
767 Expert 512MB
I have changed these things:(see attachment)

- COMBBclients :
The list is sorted and when You type a letter the list jumps to the first name that begins with the letter(s).

- The tabs: because the elements are in a FRAME and the elements are GROUPED (for easy layout modifications), the tabs act different !
They act in LAYERS: elements on the first level are the group "PO", "Date", frames and the command buttons.
In each frame the groups have there own tabindex and in these groups the elements have there tabindex.
If you jumps from "date" it goes to the next FRAME and in this frame to the first group and in this group to the first element.
It's possible to bypass the groups tabstops by setting the Tabstop to FALSE.
I have modiffied them but if the layput changes, they have to be addapted.
Or you can delete the GROUPS and FRAMES but the modiffication of the layout becommes more difficult.

- The macro's are in the Module =
Show_Add_Data_Form
Show_Report_Sheet
Show_Report_Form
You can call them with Macro - Run.
Attached Files
File Type: zip Form data not going to correct date tab_v3.0.zip (85.5 KB, 57 views)
Aug 15 '10 #15
Guido Geurs
767 Expert 512MB
All data of the clients must be central (in the sheet) because it's used to search on.
It has also the advantage that there is less chance on mistakes in entering the data.

For the reports, the data of the clients is picked from the line you selected in a sheet:
For the Report FORM=
Expand|Select|Wrap|Line Numbers
  1.    With ActiveCell
  2.       .End(xlToLeft).Activate
  3.       Set DATA = Range("A" & .Row & ":AQ" & .Row)
  4.    End With
For the Report SHEET=
Expand|Select|Wrap|Line Numbers
  1.    Worksheets("Report").Activate
  2.    Cells(8, 1) = DATA(1, 2)   '§ first name
  3.    Cells(8, 2) = DATA(1, 3)   '§ last name
  4.    Cells(9, 1) = DATA(1, 6)   '§ street name
  5.    Cells(9, 2) = DATA(1, 5)   '§ street no
  6.    Cells(10, 1) = DATA(1, 8)  '§ city
  7.    Cells(11, 1) = DATA(1, 7)  '§ tel no
Aug 15 '10 #16

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

Similar topics

4
by: Funnyweb | last post by:
I have just notices that the date() function is not returning the correct date/time on my "server". I am running apache2 on my winxp pro laptop. My system clock is set to the correct date,...
3
by: Randy | last post by:
I want to set up a table where I can enter dates that will prevent data entry of Dates in the Main table. I have done this in Approach by linking two tables and setting up a validation formula...
1
by: LD | last post by:
Hi, I'm pulling my hair out!! My problem is, I need to automatically upload a zip file along with 3 other pieces of text data to a web server and wait for it's xml response. Basically a...
4
by: Alex Sibilev | last post by:
Hello, I have a really weird problem I've been trying to solve it without any luck for the last couple of hours :( I'm writing a "conference board" application (quite similar to ASP.NET...
7
by: Mark Waser | last post by:
Hi all, I'm trying to post multipart/form-data to a web page but seem to have run into a wall. I'm familiar with RFC 1867 and have done this before (with AOLServer and Tcl) but just can't seem...
1
by: neil-holmquist | last post by:
i have this code: var parameters = "temp1=1" http_request.onreadystatechange = saveHatHandler; http_request.open('POST', url, true); http_request.setRequestHeader("Content-type",...
2
by: savigliano | last post by:
hello, i am doing a date comparation and i have reallize that the data i have in my database (general date format) it is causing me problems, and because i donīt need the time data i would like to...
6
by: Boldgeek | last post by:
I am trying to develop an app that will allow automatic updating of a web form which uses multipart/form-data enctype (as it MIGHT be sending an image) I have an example form, which when...
4
by: vunet.us | last post by:
Hi all, I am converting my app to AJAX-based. I have a form that submits some data including images. When I use AJAX XmlHttpRequest I am unable to submit the form with...
1
by: suffolkmike | last post by:
Hello, I am currently building a daily reporting log for my company. A user will input data into a form, the form then stores on the database, another user will sign on to view the data from the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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
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...

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.