Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 24th, 2012, 02:02 AM
da.ameta da.ameta is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2012
Posts: 1 da.ameta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 37 sec
Reputation Power: 0
In Excel form next or previous cmd button doesn't work

hi all
I am new in dev shed. iam working on excel form which is use to data entry but there is littile mistake. in my excel form next or previous cmd button doesn't show data from sheet to form here is code :-
Private Sub cmdNext_Click()
If ActiveCell.Column = Columns.Count Then
MsgBox "There is no next cell"
Exit Sub
End If

ActiveCell.Offset(0, 1).Select
End Sub

Private Sub cmdpre_Click()
If ActiveCell.Column = 1 Then
MsgBox "There is no previous cell"
Exit Sub
End If

ActiveCell.Offset(0, -1).Select
End Sub

Private Sub cmdsave_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("sheet1")
'find first empty row in database
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
'check for a student number
If Trim(Me.txtsrnu.Value) = "" Then
Me.txtsrnu.SetFocus
MsgBox "PLEASE ENTER A SERIAL NUMBER !!!"
Exit Sub
End If


If Trim(Me.txtname.Value) = "" Then
Me.txtname.SetFocus
MsgBox "PLEASE ENTER A NAME !!!"
Exit Sub
End If


'copy the data to the database
ws.Cells(iRow, 1).Value = Me.txtsrnu.Value
ws.Cells(iRow, 2).Value = Me.txtname.Value
ws.Cells(iRow, 3).Value = Me.txtfname.Value
ws.Cells(iRow, 4).Value = Me.txtdob.Value
ws.Cells(iRow, 5).Value = Me.txtadd.Value
ws.Cells(iRow, 6).Value = Me.txtgender.Value
ws.Cells(iRow, 7).Value = Me.txtcat.Value
ws.Cells(iRow, 8).Value = Me.txtquali.Value
ws.Cells(iRow, 9).Value = Me.txtper.Value
ws.Cells(iRow, 10).Value = Me.txtafnu.Value
ws.Cells(iRow, 11).Value = Me.txtnu.Value
ws.Cells(iRow, 12).Value = Me.txtenrnu.Value

'clear the data
Me.txtsrnu.Value = ""
Me.txtname.Value = ""
Me.txtfname.Value = ""
Me.txtdob.Value = ""
Me.txtadd.Value = ""
Me.txtgender.Value = ""
Me.txtcat.Value = ""
Me.txtquali.Value = ""
Me.txtper.Value = ""
Me.txtafnu.Value = ""
Me.txtnu.Value = ""
Me.txtenrnu.Value = ""
MsgBox "RECORD SAVED SUCCESSFULLY!!!"
Me.txtsrnu.SetFocus
End Sub
Private Sub txtadd_Change()

On Error Resume Next

txtadd = UCase(txtadd)

On Error GoTo 0


End Sub

Private Sub txtafnu_Change()

On Error Resume Next

txtafnu = UCase(txtafnu)

On Error GoTo 0

End Sub

Private Sub txtcat_Change()

On Error Resume Next

txtcat = UCase(txtcat)

On Error GoTo 0

End Sub

Private Sub txtdob_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Me.txtdob.Value = Format(Me.txtdob.Value, "dd/mm/YYYY")
End Sub

Private Sub txtenrnu_Change()

On Error Resume Next

txtenrnu = UCase(txtenrnu)

On Error GoTo 0

End Sub
Private Sub txtfname_Change()

On Error Resume Next

txtfname = UCase(txtfname)

On Error GoTo 0


End Sub

Private Sub txtgender_Change()
On Error Resume Next
txtgender = UCase(txtgender)
On Error GoTo 0
End Sub

Private Sub txtname_Change()
On Error Resume Next
txtname = UCase(txtname)
On Error GoTo 0
End Sub



Private Sub txtnu_Change()
OnlyNumbers
End Sub

Private Sub txtper_Change()
OnlyNumbers

End Sub

Private Sub txtsrnu_Change()


OnlyNumbers

End Sub





Private Sub OnlyNumbers()



If TypeName(Me.ActiveControl) = "TextBox" Then

With Me.ActiveControl

If Not IsNumeric(.Value) And .Value <> vbNullString Then

MsgBox "Sorry, only numbers allowed"

.Value = vbNullString

End If

End With

End If



End Sub



Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)

If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox "Please use the close button!"
End If
End Sub

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > In Excel form next or previous cmd button doesn't work

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap