|
People here, generally, do not spoon feed. Also, you are doing a course that expects you to learn something. If you search the web and find some code and just copy paste it to pass, then there no use doing the course.
Here are a couple of things to think about:
1. How are you going to send the notification? Mail, popup, alarm etc?
2. What kind of application this is? Windows based, web based?
At a very high level, your application should work like this:
Any time something is sold, you will be updating the quantity in database. At the same time place check such that when the product quantity goes below a certain level send your notification.
In the end it is your project so you should be thinking about this. In case you get stuck during the project and have a specific question, post it here and and I am sure some one will show you the right way.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
yea i guess ur right...thx for the tips anyway...
|
|
|
|
|
I wasn't trying to give you a smart ass answer. I wasn't sure but I though you were just asking how to display the message. If you were asking how to do this project though it's like d@nish said, people will point you in the right direction or give you 1 or 2 lines of code but they aren't going to write your whole program for you.
|
|
|
|
|
MikeMarq wrote: I wasn't sure but I though you were just asking how to display the message.
4th year compsci student needs a tutorial on MessageBox.Show()? Ouch. Not much belief in the education system, huh?
|
|
|
|
|
I am a relatively new VBA user and this is my first post (formatted better).
I am using Excel 2002 sp3 with VBA (help shows VB 6.03 version 1024) on an XP sp3 machine.
I have a project with one workbook that has one form - frmRecordJob.
This form has a calendar control, a combo box, 2 listboxes, some labels, and 2 text boxes.
The 2 list boxes (lstCode1 and lstCode2) are in a frame.
lstCode2 was created by copy/paste from lstCode1.
Checking their properties shows them to be identical except for the tab indices and top properties.
The value and text properties are both empty, with no blanks in field.
Both listboxes get their row source set in the form initialization routine.
These listboxes are not changed in any project code other than the form initialize event.
If I close Excel, restart Excel, open the workbook, immediately start the VB editor, open and step through the form initialize procedure, the following occurs:
Private Sub UserForm_Initialize()
*** some irrelevant code left out here ***
With lstCode1
.RowSource = strRngBaseTable
End With HERE lstCode1.Value = ""
With lstCode2
.RowSource = strRngBaseTable
End With HERE lstCode2.Value = null
End Sub
Why are the 2 list box values be different at this point?
I don't know if they should be "" or null, but I would think they would be the same.
Would they normally be "" or null?
At the end of the initialize procedure the form is shown and the 2 list boxes do not have any values selected. This is correct.
The form has a command button on it. If this button is clicked (no other mouse or keyboard actions) the click event procedure shows the following.
Private Sub cmdOK_Click()
Dim lng01 As Long
Dim bValidateNewGroom() As Variant
ReDim aryGroomDataFlags(1 To 6) As Variant
'If no Code1 entered
If IsNull(lstCode1) Then 'HERE lstCode1 = "" as before
lstCode1.Value = "" 'This line is not executed (correct)
End If 'HERE lstCode1 = "" as before (correct)
'If no Code2 entered
If IsNull(lstCode2) Then 'HERE lstCode2 = null (as before)
lstCode2.Value = "" 'This line IS executed (correct)
End If 'HERE lstCode2 = null (should be "")
The following (next) statement blows up with runtime error 94
"Invalid use of null"
I think this is because lstCode2 is null
'If new job data is valid
aryGroomDataFlags = ValidateGroomData_
(calGroomDate.Value, _
cmbAnimalName.Value, _
lstCode1.Value, _
lstCode2.Value, _
txtExtra1Charge.Value, _
txtExtra2Charge.Value)
My questions:
Why would the 2 list boxes be initialized differently (1="",2=null) ?
Why after lstCode2 is set to "" it still shows its value as null?
|
|
|
|
|
Hi,
do not create a new thread, you could as well have edited the existing thread.
My answer there is still valid.
|
|
|
|
|
I am looking for how to reset my listbox to the first item, which is "blank". I am selecting answers to survey questions, and then copying and pasting them to another worksheet. I know how to do this in VB. What I want to also do, is reset the listbox's to the first item, which is simply Blank. I am using Excel 2007 with Vista.
The linked fill range is AG1:AG6, with AGI being Blank. The linked cell is C100.
I'm sure this is not a difficult thing to do, but i simply need some assistance in determing how best to get the listbox back to the blank position
Thank you very much
Marty
|
|
|
|
|
Hi,
this isn't clear.
if you want to change the content, work on ListBox.Items; that collection has a Clear() method.
if you want to scroll the ListBox, set ListBox.TopIndex
|
|
|
|
|
Normally when we using 'Appendtext' method of a text box, the text will append to end of existing text in the text box. But i want to know that is there method to append text to specific location of a text box. As a example i have two text boxes named text1 and text2. When i am typing in textbox1, the text will append to textbox2 as same time. Now i want to append this text to textbox2 to the specific location (to beginning or to middle or somewhere) not to end. I hope your kind reply and sorry for my bad english.
|
|
|
|
|
You need the String.Insert method.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
thank you d@nish for your fast reply. I have another question. when we change cursor location of a text box, how can I get cursor location as a number. As a example when i put cursor beginning of the text or any other location i want to get a value indicating cursor location.( When I put the cursor beginning of the text then the cursor location will be 0, and when I put the cursor end of the text then the cursor location will be length of the text)
|
|
|
|
|
There is a thing called documentation; you can retrieve it easily by entering the class name of interest and maybe the word MSDN into the Google search box. Read and learn, don't ask the world to spoon feed you.
|
|
|
|
|
hey, I found it. Thanks for your idea.
|
|
|
|
|
Good. Now discover the world, and come back when you have harder questions!
|
|
|
|
|
Hello,
I am facing with a strange problem when I read values from a dataset table. When I make a new row entry in to datatable ("Expenses"), I assumed that it would generate the RecordNumber (Primary Key) as it has already been defined in the original database table. The record number uses auto increment (seed= 100, and AutoIncrement value = 5). However, when a make a new row entry into dataset table, it doesn't produce a new record number but -1. Do I have to manually create a RecordNumber to use in dataset table?
When I tried to read from datatable and put the value into Listview, I realized that it puts explanation instead of RecordNumber into RecordNumber column in the Listview. If you know the solution, please let me know.
Regards.
WHERE DO I MAKE A MISTAKE?
Dim NewRow As BPRO.ExpensesRow = BPRO.Expenses.NewRow()
NewRow("CategoryNumber") = CInt(Category.SelectedValue)
NewRow("Currency") = Currency.SelectedItem
NewRow("PaidAs") = Paidas.SelectedItem
NewRow("DateRecorded") = DatePaid.Value.ToShortDateString
NewRow("Explanation") = Trim(Explanation.Text)
NewRow("Amount") = CDec(Amount.Text)
NewRow("CreditCardNumber") = CInt(Whichcreditcard.SelectedValue)
BPRO.Expenses.Rows.Add(NewRow)
ExpensesTableAdapter1.Insert(CInt(Category.SelectedValue), _
Currency.SelectedItem, _
Paidas.SelectedItem, _
DatePaid.Value.ToShortDateString, _
Trim(Explanation.Text), _
CDec(Amount.Text), _
CInt(Whichcreditcard.SelectedValue))
LI.Text = xrow("RecordNumber")
ListView1.Items.Add(LI)
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
JUNEYT wrote: it doesn't produce a new record number but -1.
New records get negative numbers because the dataset hasn't been written back to the database yet. The database always assigns the key values, not your code. Update the database with the changes being held in the dataset and your new records will get their keys will get updated with real values.
|
|
|
|
|
I am a relatively new VBA user and this is my first post.
I am using Excel 2002 sp3 with VBA (help show VB 6.03 version 1024 on an XP sp3 machine.
I have a project with one workbook that has one form - frmRecordJob.
This form has a calendar control, a combo box, 2 listboxes, some labels, and 2 text boxes.
The 2 list boxes (lstCode1 and lstCode2) are in a frame. lstCode2 was created by copy/paste from lstCode1.
Checking their properties shows them to be identical except for the tab indices and top properties.
Both get their row source set in the form initialization routine.
These listboxes are not changed in any project code other than the form initialize event.
If I close Excel, restart Excel, open the workbook, start the VB editor, open and step through the form initialize procedure, the following occurs:
Private Sub UserForm_Initialize()
*** some code here that does not reference the list boxes ***
*** HERE indicates this line is highlighted during debug ***
With lstCode1
.RowSource = strRngBaseTable
End With HERE lstCode1 value = ""
With lstCode2
.RowSource = strRngBaseTable
End With HERE lstCode2 = null
End Sub
Why would the 2 list box values be different at this point?
Would they normally be "" or null?
At the end of the initialize procedure the form is shown and the 2 list boxes do not have any values selected. This is correct.
The form has a command button on it. If this clicked without any changes made the click event shows the following.
Private Sub cmdOK_Click()
Dim lng01 As Long
Dim bValidateNewGroom() As Variant
ReDim aryGroomDataFlags(1 To 6) As Variant
'If no Code1 entered
If IsNull(lstCode1) Then HERE lstCode1 = "" as before
lstCode1.Value = "" This line is not executed (correct)
End If HERE lstCode1 = "" as before (correct)
'If no Code2 entered
If IsNull(lstCode2) Then HERE lstCode2 = null as before
lstCode2.Value = "" This line IS executed (correct)
End If HERE lstCode2 = null (should be "")
'If new job data is valid
aryGroomDataFlags = ValidateGroomData(calGroomDate.Value, _ HERE blows up with runtime error 94
cmbAnimalName.Value, _ "Invalid use of null"
lstCode1.Value, _ I think this is because lstCode2 is null
lstCode2.Value, _
txtExtra1Charge.Value, _
txtExtra2Charge.Value)
My questions:
Why would the 2 list boxes be initialized differently (1="",2=null) ?
Why after lstCode2 is set to "" it still shows its value as null?
|
|
|
|
|
IMO you did something wrong while copy/paste/editing the ListBox code.
you need two "new ListBox" fragments in pretty much the same code location, I suggest you look for them and compare them.
|
|
|
|
|
I'm confused
I read your reply as indicating that when I copied and pasted the code from my project to this forum dialog I had messed up the formatting by not using tags. That was correct. I fixed it and reposted. Your 2nd reply:
Hi,
do not create a new thread, you could as well have edited the existing thread.
My answer there is still valid.
Sorry I created a new thread.
But what 'answer there' ?
All I saw was a needed suggestion about proper posting. Am I misreading your reply?
There was no copy/paste/edit of 'listbox code' in the project.
The copy/paste I had done was to copy the control itself initially during design time.
I must be missing something.
Could you better explain what you mean?
Thank in advance.
|
|
|
|
|
right above here, I already said "you need two "new ListBox" fragments in pretty much the same code location" which IMO is still the correct answer to your problem.
|
|
|
|
|
I must really be dense because I can't understand what you are saying.
Are you saying that I need two 'new listbox' fragments in my post (to make it more readable) or in the project itself?
Since 'listbox fragment' is not something I had heard in relation to VB, I assumed you were talking about the post, so I fixed the section where the 'listbox code' had been improperly formatted and my added comments did not appear correctly. In the new post the code matches the project. (It did in the original also though very hard to tell with the comments)
If you were talking about the code itself, what do you mean by 'two "new listbox" fragments'?
'Listbox fragments' - don't know what that means.
Code fragments? That say what?
By saying 'new' do you mean that I need to delete the listboxes and recreate them? I did that once already.
Please forgive my lack of comprehension.
|
|
|
|
|
is there anywhere in your code something that reads like "new ListBox"?
there should be two, as you want to work with two ListBoxes.
|
|
|
|
|
Thanks for clarifying.
I don't know if you looked at the corrected post, but it now shows:
Private Sub UserForm_Initialize()
*** some irrelevant code left out here ***
With lstCode1
.RowSource = strRngBaseTable
End With HERE lstCode1.Value = ""
With lstCode2
.RowSource = strRngBaseTable
End With HERE lstCode2.Value = null
End Sub
The list boxes were added by using the control toolbox when when the form was created.
These are NOT 'new' listboxes.
They, and their controls, exist at startup.
Notice that the two 'With' statements reference lstCode1 and lstCode2, two distinct listboxes.
Thanks for your help.
|
|
|
|
|
if you use Visual Studio
if you have the solution pane open
if you have ever clicked the "show all files" button
if your form happens to be called Form1
if you used Visual Designer to add a first ListBox and a second ListBox
and if you did change their default names to lstCode1 and lstCode2
then you will have a file called "Form1.Designer.vb" (that is where Visual Designer stores all the things you do graphically when designing Form1), in which you will find both these lines:
Me.lstCode1 = New System.Windows.Forms.ListBox
Me.lstCode2 = New System.Windows.Forms.ListBox
which is fine, and allows you to then do things with lstCode1 and lstCode2 as you did in the code you showed earlier.
And if you keep adding and removing ListBoxes with all kinds of names and changing code files without really understanding what you are doing, then you are likely to get variables that never get assigned an object to, so your code would fail.
I suggest you buy and study a book on VB.NET and start looking around inside your test projects.
|
|
|
|
|
if you use Visual Studio - no, I am NOT using Visual Studio. As stated, I am using the VBA that comes with Excel 2002 (Office XP Pro)
if you have the solution pane open - don't know what that is
if you have ever clicked the "show all files" button - don't know what that is
if your form happens to be called Form1 - as stated the form name is "frmRecordJob"
if you used Visual Designer to add a first ListBox and a second ListBox
and if you did change their default names to lstCode1 and lstCode2 - I used the pane on the upper left of VBE (title says VBAProject-JobLog.xls' to insert the new user form at initial design time. I don't believe this is what you are referring to as 'Visual Designer'.
No file "Form1.Designer.vb" exists on my system.
What leads you to believe that I "keep adding and removing ListBoxes with all kinds of names and changing code files without really understanding what you are doing"?
I had put the two listboxes in using the form designer and changed their names to something meaningful, as recommended. I removed them and recreated them because of the problems I was having. I changed the code files because I didn't want to leave them empty, that is, I actually wanted something to occur, for example, when the OK button is clicked.
As stated in my post, I am using Excel 2002 and VB 6.03 version 1024.
I don't know if your comment about getting VB.Net books was meant to be snide, but I don't see how that would help in this situation, since I am not using VB.Net. I have numerous VBA books from Sams, WROX, Microsoft Press, Que, and M&T books, and have looked through all of them trying to resolve this issue.
Thanks again for your help.
|
|
|
|
|