Data entry form(search option)

  • Thread starter Thread starter AccessUser30
  • Start date Start date
A

AccessUser30

Hello, can anyone provide source codes for the following command buttons: New
records, search records. I need to write command codes for some buttons
within my form:
Add new record
search
edit (not sure)
 
Easiest thing to do is add a command button. Then, pick the one you want to
do. This gives you all the code you'd need...

DoCmd.GoToRecord , , acNewRec


Screen.PreviousControl.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70
 
my new record button is not working, can someone help with the problem.

source code below;

Option Compare Database

Private Sub Combo16_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[ID] = " & Str(Nz(Me![Combo16], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

Private Sub Form_CommandEnabled(ByVal Command As Variant, ByVal Enabled As
Object)

End Sub

Private Sub New_Record_Click()
DoCmd.GoToRecord , , acNext
End Sub

Private Sub search_records_Enter()

End Sub
 
my new record button is not working, can someone help with the problem.

source code below;

Option Compare Database

Private Sub Combo16_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[ID] = " & Str(Nz(Me![Combo16], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

Private Sub Form_CommandEnabled(ByVal Command As Variant, ByVal Enabled As
Object)

End Sub

Private Sub New_Record_Click()
DoCmd.GoToRecord , , acNext
End Sub

Change acNext to acNewRecord in order to go to the new record.
Private Sub search_records_Enter()

End Sub

Delete this entire routine (three lines, one blank), as it does nothing.
 
how should i approach creating a new record command button? how do i write
the source code so the users can click the command button? i'm completely
new to source coding, so i'm clueless on how to start.

John W. Vinson said:
my new record button is not working, can someone help with the problem.

source code below;

Option Compare Database

Private Sub Combo16_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[ID] = " & Str(Nz(Me![Combo16], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

Private Sub Form_CommandEnabled(ByVal Command As Variant, ByVal Enabled As
Object)

End Sub

Private Sub New_Record_Click()
DoCmd.GoToRecord , , acNext
End Sub

Change acNext to acNewRecord in order to go to the new record.
Private Sub search_records_Enter()

End Sub

Delete this entire routine (three lines, one blank), as it does nothing.
 
how should i approach creating a new record command button? how do i write
the source code so the users can click the command button? i'm completely
new to source coding, so i'm clueless on how to start.

You don't need to learn coding for this - the Command Button wizard on the
toolbox will give you that as an option. Just be sure the magic wand icon is
selected, add a new command button, and choose the option to "go to a new
record".

Or, use a macro GoToRecord in the button's Click event, if you want to do it
yourself.
 
Back
Top