• Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Database Help!

rhain

New Coder
Hello All, I need some help with the back end coding for this project. I have got a picture of how I want the form to be setup and I started to write the code, but every time I get somewhere, I seem to run into a new problem. Any thoughts on how to fix. I don't mean to ask for an entire wall of code but I feel like I royally messed it up. HELP!

Code:
Sub Reset()

    Dim iRow As Long
    
    iRow = [Counta(Database!A:A] ' identifying the last row
    
    With frmForm
        .txtdate = ""
        .txtlocation = ""
        .Txtturnedin = ""
        .txtturnedinby = ""
        .txtowner = ""
        .OptionButton1 = False
        .OptionButton2 = False
        .OptionButton3 = False
        .OptionButton4 = False
        .OptionButton5 = False
        .OptionButton6 = False
        .OptionButton8 = False
        .OptionButton7 = False
        .Txtbrand = ""
        .txtmodel = ""
        .txtcolor = ""
        .OptionButton9 = False
        .OptionButton10 = False
        .OptionButton11 = False
        .txtdescription = ""
        
        .lstDatabase.ColumnCount = 11
        .lstDatabase.ColumnCount = True
        
        .lstDatabase.ColumnWidths = "50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 250"
        
        If iRow > 1 Then
            
            .lstDatabase.RowSource = "[email protected]:I" & iRow
        Else
        
            .lstDatabase.RowSource = "database!A2:I2"
            
        End If
          
    
    End With
    
        
End Sub

Sub Submit()

    Dim sh As Worksheet
    Dim iRow As Long
    
    Set sh = ThisWorkbook.Sheets("database")
    
    iRow = [Counta(Database!A:A)] + 1
        
    With sh
    
        .Cells(iRow, 1) = iRow - 1
        
        .Cells(iRow, 2) = frmForm.txtdate.Value
        
        .Cells(iRow, 3) = frmForm.txtlocation.Value
        
        .Cells(iRow, 4) = frmForm.Txtturnedin.Value
        
        .Cells(iRow, 5) = frmForm.txtturnedinby.Value
        
        .Cells(iRow, 6) = frmForm.txtowner.Value
        
        .Cells(iRow, 7) = IIf(frmForm.OptionButton1.Value = True, "electronics", "wallet/purse", "medical devices", "jewelry", "clothing", "keys", "Identifications", "Other")
        
        
        .Cells(iRow, 8) = frmForm.Txtbrand.Value
        
        .Cells(iRow, 9) = frmForm.txtmodel.Value
        
        .Cells(iRow, 10) = frmForm.txtcolor.Value
        
        .Cells(iRow, 11) = frmForm.OptionButton9.Value = True
        
        .Cells(iRow, 12) = fromform.txtdescription.Value
        
        .Cells(iRow, 13) = Application.UserName
        
        .Cells(iRow, 13) = [text(now(),"DD-MM-YYYY HH:MM:SS")]
    
    End With
    

End Sub
 

Antero360

King Coder
Hello All, I need some help with the back end coding for this project. I have got a picture of how I want the form to be setup and I started to write the code, but every time I get somewhere, I seem to run into a new problem. Any thoughts on how to fix. I don't mean to ask for an entire wall of code but I feel like I royally messed it up. HELP!

Code:
Sub Reset()

    Dim iRow As Long
   
    iRow = [Counta(Database!A:A] ' identifying the last row
   
    With frmForm
        .txtdate = ""
        .txtlocation = ""
        .Txtturnedin = ""
        .txtturnedinby = ""
        .txtowner = ""
        .OptionButton1 = False
        .OptionButton2 = False
        .OptionButton3 = False
        .OptionButton4 = False
        .OptionButton5 = False
        .OptionButton6 = False
        .OptionButton8 = False
        .OptionButton7 = False
        .Txtbrand = ""
        .txtmodel = ""
        .txtcolor = ""
        .OptionButton9 = False
        .OptionButton10 = False
        .OptionButton11 = False
        .txtdescription = ""
       
        .lstDatabase.ColumnCount = 11
        .lstDatabase.ColumnCount = True
       
        .lstDatabase.ColumnWidths = "50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 250"
       
        If iRow > 1 Then
           
            .lstDatabase.RowSource = "[email protected]:I" & iRow
        Else
       
            .lstDatabase.RowSource = "database!A2:I2"
           
        End If
         
   
    End With
   
       
End Sub

Sub Submit()

    Dim sh As Worksheet
    Dim iRow As Long
   
    Set sh = ThisWorkbook.Sheets("database")
   
    iRow = [Counta(Database!A:A)] + 1
       
    With sh
   
        .Cells(iRow, 1) = iRow - 1
       
        .Cells(iRow, 2) = frmForm.txtdate.Value
       
        .Cells(iRow, 3) = frmForm.txtlocation.Value
       
        .Cells(iRow, 4) = frmForm.Txtturnedin.Value
       
        .Cells(iRow, 5) = frmForm.txtturnedinby.Value
       
        .Cells(iRow, 6) = frmForm.txtowner.Value
       
        .Cells(iRow, 7) = IIf(frmForm.OptionButton1.Value = True, "electronics", "wallet/purse", "medical devices", "jewelry", "clothing", "keys", "Identifications", "Other")
       
       
        .Cells(iRow, 8) = frmForm.Txtbrand.Value
       
        .Cells(iRow, 9) = frmForm.txtmodel.Value
       
        .Cells(iRow, 10) = frmForm.txtcolor.Value
       
        .Cells(iRow, 11) = frmForm.OptionButton9.Value = True
       
        .Cells(iRow, 12) = fromform.txtdescription.Value
       
        .Cells(iRow, 13) = Application.UserName
       
        .Cells(iRow, 13) = [text(now(),"DD-MM-YYYY HH:MM:SS")]
   
    End With
   

End Sub
Hey there, could you please provide a little more details of the issues you are having? What is the purpose of the code? What is the overall goal of the program?
 

GGWOSG

New Coder
Hey there, could you please provide a little more details of the issues you are having? What is the purpose of the code? What is the overall goal of the program?
Hey there,

I have a very similar code. Its a user entry form. Basically a team of 8 are using this form to enter 'call details'. I created the form using a youtube video. So whenever there is a new debug, I am unable to fully fix it. The form in general works. However, if you copy and paste data from another excel sheet, or potentially two users saves at the same time. It pops up with a debug. Runtime error 380.

.1stDatabase.RowSource ="database!A2:I" always gets highlighted when the debug appears. I personally don't often encounter this error as I know how to 'work around' it. But for the team of 8, they aren't as technical and are using the form like any other form.
 

Antero360

King Coder
Hey there,

I have a very similar code. Its a user entry form. Basically a team of 8 are using this form to enter 'call details'. I created the form using a youtube video. So whenever there is a new debug, I am unable to fully fix it. The form in general works. However, if you copy and paste data from another excel sheet, or potentially two users saves at the same time. It pops up with a debug. Runtime error 380.

.1stDatabase.RowSource ="database!A2:I" always gets highlighted when the debug appears. I personally don't often encounter this error as I know how to 'work around' it. But for the team of 8, they aren't as technical and are using the form like any other form.
A bit of digging and sounds like this is an issue with trying to access an object you have no access to... not sure if you may have come across this but I think this may help clarify a few things...
 
Top