Hello and TIA for your consideration.
I have created several db's for a non-profit and they want custom
navigation buttons to display "You are on the first record, last
record, etc". With this ng help I've created code for all except the
add new record command button.
If I create individual sub functions behind each form, no problem.
The problem is I am trying to create a re-usable module.
CBF (works):
Private Sub cmdNewRec_Click ()
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClo ne
If Me.NewRecord Then
MsgBox "You are on a blank record", vbOKOnly, "Data Navigation"
ElseIf Not rs.EOF Then
DoCmd.GoToRecor d , , acNewRec
Me.txt_radioNbr .SetFocus
End If
Set rs = Nothing
End Sub
Function (add new record is stepped into but the cursor stays on
current record):
Function NavButtons(strN av As String)
'Purpose: Re-usable module for navigating the form
'Called by: Navigation buttons on forms
'Variables: First, Previous, Next, Last and New
'Returns: Nothing
'Created: Terry Wickenden
Dim frmCurrent As Form
Dim rsNavigate As DAO.Recordset
On Error GoTo ErrNavButtons
Set frmCurrent = Screen.ActiveFo rm
Set rsNavigate = frmCurrent.Reco rdsetClone
Select Case strNav
Case "First"
If frmCurrent.Curr entRecord = 1 Then
MsgBox "You are on the first record", vbOKOnly, "Data Navigation"
Else
rsNavigate.Move First
End If
Case "Prev"
If frmCurrent.Curr entRecord = 1 Then
MsgBox "You are on the first record", vbOKOnly, "Data
Navigation"
Else
rsNavigate.Move Previous
End If
Case "Next"
If frmCurrent.NewR ecord Then
MsgBox "You are on a blank record", vbOKOnly, "Data
Navigation"
ElseIf frmCurrent.Curr entRecord =
frmCurrent.Reco rdsetClone.Reco rdCount Then
MsgBox "You are on the last record", vbOKOnly, "Data
Navigation"
Else
rsNavigate.Move Next
End If
Case "Last"
If frmCurrent.Curr entRecord =
frmCurrent.Reco rdsetClone.Reco rdCount Then
MsgBox "You are on the last record", vbOKOnly, "Data
Navigation"
Else
rsNavigate.Move Last
End If
Case "new"
If frmCurrent.NewR ecord Then
MsgBox "You are on a blank record", vbOKOnly,
"Data Navigation"
Else
DoCmd.GoToRecor d , , acNewRec
End If
End Select
frmCurrent.Book mark = rsNavigate.Book mark
Set rsNavigate = Nothing
ExitNavButtons:
Exit Function
ErrNavButtons:
MsgBox Error$
Resume ExitNavButtons
End Function
Again Thanks for any suggestions. 0 1952 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Robert Neville |
last post by:
I am having some trouble with some old code revolving around custom
form navigation buttons. My main form has a sub-form with these custom
navigation buttons. In other words, the code should be modular and
work across forms and sub-forms. My previous code was taken from the
Access Expert Solutions 97 (Leszynski) many years ago. As my database
became more complex with multiple sub-forms and intricate combo boxes,
the code faltered.
Some...
|
by: Ellen Manning |
last post by:
I'm developing an A2K adp that contains doctor info and the months
they are not available for teaching. A doctor can be unavailable for
some months for one year and other months for another year. I want
the user to enter the year then use a multi-select list box to choose
the months not available, then go to a fresh screen, enter another
year and choose the months not available for that year, and so on. In
the table, there is one record...
|
by: dixie |
last post by:
I have some code that adds new records into a table for each ID in a list
box when a button on a form is clicked. This works fine. My problem now is
that I wish to be able to edit all the records for people whose ID is in the
list box. I made minor changes to the code (mainly replacing rs.AddNew with
rs.Edit)and it appears to be updating only the first record and then
overwriting that record with the next, etc until it runs out of ID's...
|
by: Harold |
last post by:
Sat I have a customers table with the fields CustomerID and Customer and I use
the recordset.addnew method to add a new record to the table. What is the best
way to get the CustomerID of the new record after recordset.update is executed?
Recordset!CustomerID doesn't work because the recordset bookmark is on the first
record. Moving to the last record doesn't work if the recordset is based on a
query and the recordset is sorted.
Thanks!
...
|
by: pillmill |
last post by:
I replaced AddNew statments with INSERT INTO, but am unable to
write to the same tables. Foreign keys violations are
the main errors. Why are these occuring ?
Before:
set rs3= db.OpenRecordset("tblMat", dbOpenDynaset)
rs3.AddNew
rs3!Mat = Rs!Mat
rs3.Update
| |
by: MLH |
last post by:
Here's a snippet from A97 HELP on AddNew...
The record that was current before you used AddNew remains current. If
you want to make the new record current, you can set the Bookmark
property to the bookmark identified by the LastModified property
setting.
My own experience is indicating that the newly added record becomes
current during the AddNew processes and REMAINS current after .Update
method runs. This seems true even though the...
|
by: polocar |
last post by:
Hi,
I have noticed a strange behaviour of CurrencyManager objects in C# (I
use Visual Studio 2005 Professional Edition).
Suppose that you have a SQL Server database with 2 tables called
"Cities" and "Persons", and that:
"Cities" has 2 fields called "IDCity" and "NameCity"
"Persons" has 3 fields called "IDPerson", "NamePerson" and
"IDCityAddress"
with "IDCity" and "IDCityAddress" fields relationed with the
classical father-child relation...
|
by: Rational Repairs |
last post by:
I am trying to create global code for navigation use in all my forms --
including subforms. I searched, and searched, but can not find how to
globally reference a subform object. I need to have the navigation
buttons on the subform itself, but I would like to code to be global so
I can reuse it in my many subforms.
but only as a control in the partent form. So how can I change records
in a control?
I have tried to reference the...
|
by: teenagelcruise |
last post by:
hi,
i have a problem with my code which is i cannot update and addnew data into the database but i can delete the data.plz give me an idea.this is my code that i wrote.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Order Record</title>
<meta name="Microsoft Border" content="tlb, default">
</head>
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |