How can I write data into a row in Virtual Studio? (MS Access Database file" - vb.net

I would like to make a small application what can make easier my work.
I have to make one ordering process some labels where I have a plan and from the plan I have to one excel list making with the labelnames what will be printed by the Manufacturer. We have a lot of type of the label (names) but they are fixing. (160 pieces differentnames).
So I make this always if I get a new plan then I make new label-list. I do it alway by hand cell by cell.. Sometime I have to filling out 400 cell for one plan... I don’t have a lot’s of time to this..
So I started making my first Windows app with Visual Studio(in Windows From – Visual Basic).
I found some cool video, so I already have the „basics”.
I connected one MS Access database to my Project where I would like to store the datas.
And now i have trouble.. I have some Comboboxes. I would like to choose some cases and then I would like to update the database where the rows will be filled with the correct values. If its done, i can this exporting to excel and sendig forward to the Manufacturer.
I have a textbox where I write the Plan name (it linked to the database first Column)
And then:
So the Combobox1 have Sektor A, B, C, D ,E, F (six value)
The Combobox2 have 09RRU, 09RSU, 18RRU ... empty - (eight value)
The Combobox3 have 21RRU, 21RSU, 26RRU ... empty - (eight value)
The Combobox4 have ja or nein (only two value)
and so on.. I have 8 Combobox.
My Idea:
If I select the Sektor A and 09RRU , the another two is empty and nein, then I click on the Update button I would like to get back in database 09.SekA1, 09.SekA2, AISG.SekA
If I select the Sektor A and 09RRU and 21RRU and ja, then after click Update, I would like get 09.SekA1, 09.SekA2, 21.SekA1, 21.SekA2, 09.21.SekA1, 09.21SekA2, AISG.09.21.SekA
….
I can every type of labels line by line writing if needed, I think I have to do this. I don’t think so can I dynamic Arrays making which can the different String e.g. ( Text (09) & Text (.SekA) & Text(1)) creating. I just now started the VB..
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox8.SelectedIndexChanged
SektorForm1()
End Sub
Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
End Sub
Private Sub ComboBox3_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox2.SelectedIndexChanged
End Sub
Private Sub ComboBox4_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox3.SelectedIndexChanged
End Sub
Private Sub SektorForm1()
BEschriftungenDataSet.Standort.RRU18Column = "18.SekA1"
BEschriftungenDataSet.Standort.RRU21Column = "18.SekA2"
BEschriftungenDataSet.Standort.RRU26Column = "AISG.18.SekA"
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.StandortTableAdapter.Fill(Me.BEschriftungenDataSet.Standort)
ComboBox1.SelectedIndex = 5
ComboBox2.SelectedIndex = 3
ComboBox3.SelectedIndex = 3
ComboBox4.SelectedIndex = 1
ComboBox5.SelectedIndex = 1
ComboBox6.SelectedIndex = 1
ComboBox7.SelectedIndex = 1
ComboBox8.SelectedIndex = 0
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
On Error GoTo SaveErr
StandortBindingSource.EndEdit()
StandortTableAdapter.Update(BEschriftungenDataSet.Standort)
MessageBox.Show("Saved")
End Sub
Could some one for me Helping what is wrong in my code? I tried some data inserting to tha database when I choose someting in Combobox1 but it doesn't work..
I get failures: BC30526 Property'RRU18Column' is 'ReadOnly' and BC30311 Value 'String' cannot be converted to 'DataColumn'..
And giving some help how I sould staring building up my cases to my Combobox chooses..
Thanks guys

Related

How do I allow null textbox when using bindingsource Find method?

I am new to VB please assist. I have an application where I search using combo box and two textboxes. Now it is not always when all textboxes have text. Sometimes the user can search using one textbox. My problem is when I leave out a textbox that searches an integer column is using binding source find method I get : 'Input string was not in a correct format.' because the textbox is empty. My database is access database and I am searching from a gridview binding source. How can I allow txtboxIdSize to be ignored if not used? My code below:
Private Sub btnSearch_Click(sender As Object, e As EventArgs) Handles btnSearch.Click
TblDiesBindingSource.Filter = $"Descript LIKE '%{txtDescription.Text.Trim()}%'"
TblDiesBindingSource.Position = TblDiesBindingSource.Find("IDSIZE", txtIdSize.Text)
End Sub
Private Sub btnSearch_Click(sender As Object, e As EventArgs) Handles btnSearch.Click
If txtboxIdSize.TextLength > 0 then
TblDiesBindingSource.Filter = $"Descript LIKE '%{txtDescription.Text.Trim()}%'"
TblDiesBindingSource.Position = TblDiesBindingSource.Find("IDSIZE", txtIdSize.Text)
End if
End Sub

Perform Load upon after click button

I am trying to use the panel and buttons to load 2 different forms along with entity framework and ado model stuff. I am trying to load the 2nd form this picture, using the codes running on the first form since they have the same table. but what happen is whenever I close the 2nd form and try to switch on the second user from this form(driverlist), I am still getting the results that I created before on the first user, I kinda think that the 2nd form is not being loaded although I put some code:
Private Sub DriverLicense_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim user_id As Integer = Driverlist.tbxUser_id.Text
Driverlist.db = New [Emme_Subic_Transport_Corporation_Payroll].EmmeSubicEntities
Driverlist.db.UserDetails.Where(Function(c) c.isDeleted <> 1 And c.Id = user_id).Load()
UserDetailBindingSource.DataSource = Driverlist.db.UserDetails.Local
If Driverlist.tbxUser_id.Text.Count < 1 Then
MessageBox.Show("Please Select an Employee ID First", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
Drivertest.Panelswitch(Driverlist)
Else
Me.Show()
End If
End Sub
Private Sub DriverLicense_Activated(sender As Object, e As EventArgs) Handles Me.Activated
Dim user_id As Integer = Driverlist.tbxUser_id.Text
Driverlist.db = New [Emme_Subic_Transport_Corporation_Payroll].EmmeSubicEntities
Driverlist.db.UserDetails.Where(Function(c) c.isDeleted <> 1 And c.Id = user_id).Load()
UserDetailBindingSource.DataSource = Driverlist.db.UserDetails.Local
End Sub
I binded the 2nd form through other resources of data binding from the properties but still on the same resources as the first form. Im pretty new to this so please stop putting negatives on my questions. If you think I am bad at this, I know and I am sorry. by the way this is the code from the buttons and panel if that helps. Thanks everyone.
Sub Panelswitch(Panel As Form)
PanelControl.Controls.Clear()
Panel.TopLevel = False
PanelControl.Controls.Add(Panel)
Panel.Show()
End Sub
Private Sub Btntest_Click(sender As Object, e As EventArgs) Handles Btntest.Click
Panelswitch(Driverlist)
End Sub
Private Sub Btntest2_Click(sender As Object, e As EventArgs) Handles btntest2.Click
Panelswitch(DriverLicense)
End Sub
There are number of things I would avoid, just looking at your pictures, but that goes beyond your question.
Secondly, agreed with the comment, you should revise your question further (I see you tried, but still, it's neither complete or clear).
If I understand correctly, you have container PanelControl, which you fill either with a form DriverList or DriverLicence. I just want to make sure - are you sure you have your instances corectly set? Because I would expect that the switch would act only for displaying correct form, but should behave differently for the [persistent] list DriverList and DriverLicence, which should be probably a new instance every time you want to add a licence. But this code is not shown, just guessing the problem might be along those lines. There are quite few design possibilities, I guess.
Simplified, the point is:
Private Sub Btntest2_Click(sender As Object, e As EventArgs) Handles btntest2.Click
Dim DriverLicenceInstance as new DriverLicence
Panelswitch(DriverLicenseInstance)
End Sub
I also think, that you might have your binding set incorrectly for the 2nd form, the DriverLicence. I'm not proficient in .NET binding, but it seems to me that you declare the bindings as two separate things (comes from the copying the code?). But what you probably need to do is to use the same binding source for both parts. See here: A-Detailed-Data-Binding-Tutorial.

Visual Basic - Displaying a combo box entry over a textbox

to keep it short and simple, I am attempting to display a number selected through a combo box on a second form through a label.
Here are the bits that are relevant to the issue I am having:
for i = 1 To 31
cmb_days.Items.Add(i)
next
' Populating combo box
days = cmb_days.text
frm_result.lbl_renting = "Renting for " & days & " Days"
I have tried using other variants such as cmb_days.selecteditem to no avail
I am also kinda having issues with like telling my code to do things with whatever number is actually selected in the combo box, idk I am veryyyyy new
That looks more or less correct.. But the question is where your call to update the label occurs in your code...
This is a minimal working example, with just a ComboBox on a form:
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
For i = 1 To 31
ComboBox1.Items.Add(i)
Next
End Sub
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
Me.Text = ComboBox1.Text
End Sub
End Class
The update of the label (in this case the text of the form, but it works exactly the same with a label on a different form) occurs in the SelectedIndexChanged event of ComboBox1.
If you copied your code straight from the project, you haven't had time to select anything yet, so the Text property will be empty.

combox selected index didnt work on picturebox

Now what i was doing is when i click a button group box 1 and group box 2 will show out i want to select the combobox item than the picturebox item will load
and this can be used it multiple time like when button-5 clicked the combobox item name will change and the picture will change too.
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
GroupBox1.Show()
GroupBox2.Show()
comboboxselectdiffrent.Items.Add("pizza_ChickenSupreme")
comboboxselectdiffrent.Items.Add("pizza_CockadoodleBacon")
If comboboxselectdiffrent.SelectedIndex = 0 Then
PictureBox1.Image = PIZZA_HUT_SYSTEM_NEW_VER.My.Resources.Resources.pizza_ChickenSupreme
ElseIf comboboxselectdiffrent.SelectedIndex = 1 Then
PictureBox1.Image = PIZZA_HUT_SYSTEM_NEW_VER.My.Resources.Resources.pizza_CockadoodleBacon
End If
End Sub
Can anyone tell me what i was do wrong? i have no idea why it wont work
After looking at your code personality I would have the event trigger from the combobox click, that way it will save the user having to first click on the combo to select their pizza and then having to click on a button to load the picture & details. Nevertheless try this.
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ComboBox1.Items.Add("pizza_ChickenSupreme")
ComboBox1.Items.Add("pizza_CockadoodleBacon")
ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
GroupBox1.Show()
GroupBox2.Show()
Select Case ComboBox1.SelectedItem
Case Is = "pizza_ChickenSupreme"
PictureBox1.ImageLocation = "Pictures/mypic.jpg"
Case Is = "pizza_CockadoodleBacon"
PictureBox1.ImageLocation = "Pictures/mypic1.jpg"
End Select
End Sub
End Class
Using a custom Folder within the solution explorer will be better than using a setting resource. Create a folder and drag your pictures into it and change the name of the image location to suit your needs.
Also i think using the items name is better than the items index because what happens if someone reason that indexed item is to change from 1 to 5, you would have to recode it all, but by using the items name, it has more detail as to what to look for.
If you have any problems, leave a comment and I will do my best to help you out.Happy Coding!

Form_Load doesn't execute in application

I am new to Visual Basic. I have installed Microsoft Visual Studio 2010. Created a new Windows Form Application. As an example, I made a simple program which will ask the end user to input 2 numbers and allow them to either add them or subtract the second number from the first one and display the output in a Textbox.
Now, I added another Subroutine which would be executed automatically when the Windows Form loads. This would calculate the width of the output Textbox and the Form Width and display at the bottom.
This is how the code looks like right now:
Public Class Form1
' Run this Subroutine initially to display the Form and Text box width
Private Sub Form_Load()
Label5.Text = TextBox3.Width
Label7.Text = Me.Width
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a As Integer
Dim b As Integer
a = TextBox1.Text
b = TextBox2.Text
TextBox3.Text = a + b
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim a As Integer
Dim b As Integer
a = TextBox1.Text
b = TextBox2.Text
TextBox3.Text = a - b
End Sub
End Class
While everything works correctly for the addition and subtraction, it does not display the Form and output Textbox width in the Windows Form.
I think, Form_Load() is not executing properly.
I also tried, Form_Activate() but that did not work either.
Once I am able to do this, I would like to extend this concept to resize the output Textbox along with the Form resize. However, for the purpose of understanding I wanted to see if I can execute Form_Load() successfully.
Thanks.
Form_Load doesn’t execute. For now, it’s just any other method. In order to tell VB to make this method handle the Load event, you need to tell it so:
Private Sub Form_Load(sender As Object, e As EventArgs) Handles MyBase.Loasd
Label5.Text = TextBox3.Width
Label7.Text = Me.Width
End Sub
(And add the required parameters for the event.)
A few other remarks:
Ensure that Option Strict On is enabled in your project options at all times. This will make the compiler much stricter with your code and flag more errors. This is a good thing since these errors are potential bugs. In particular, your code is very lax with conversions between different data types, these should be made explicit.
Initialise variables when you declare them, don’t assign a value in a separate statement. That is, write this:
Dim a As Integer = Integer.Parse(TextBox1.Text)
(Explicit conversion added as well.)
If you want to make a control fill the form, you can just set its Dock property appropriately in the forms editor, instead of having to program this manually.
You need to add the Handle so the app executes it automatically:
Private Sub Form_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
'...
End Sub