Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

Stored data shifts to different Excel Form Box

0

Hello,

Edited a Data Entry Form, when saving encoded values it stores it to the proper column/cell, but when I click the edit button on my VBA Form when it pulls the data from the Database worksheet it reflects it on to different ControBox of the Data Entry Form.

Answer
Discuss

Answers

0

Hello, Astrid

I could not run the form, but I noticed that in macro Submit controlBoxes and column numbers from Database sheet are not equal related as in cmdEdit code.

Form cmdEdit code

Me.txtNBIdRcvd.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 28)  Me.txtNBIremarks.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 29)    Me.txtSSSdRcvd.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 30)    Me.txtSSSremarks.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 31)    Me.cmbHDform.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 32)    Me.cmbMedgrocer.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 33)

From Sibmit code

.Cells(iRow, 27) = frmForm.txtDTremarks.Value        From here the lines are mixed
.Cells(iRow, 29) = frmForm.txtNBIdRcvd.Value         
.Cells(iRow, 28) = frmForm.txtNBIremarks.Value
.Cells(iRow, 29) = frmForm.txtSSSdRcvd.Value
.Cells(iRow, 30) = frmForm.txtSSSremarks.Value
.Cells(iRow, 31) = frmForm.cmbHDform.Value
.Cells(iRow, 32) = frmForm.cmbMedgrocer.Value

I think you can solve the problem just fixing the column numbers 27, 28, 29,... , 33.

I hope this help you.

Regards
Basilio

Discuss


Answer the Question

You must create an account to use the forum. Create an Account or Login