473,414 Members | 2,019 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Multi-List boxes and navigation

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 per year/month per doctor.

I've got the form set up and I can enter one year and the months but
can't figure out how to navigate to a fresh screen and enter the next
year. Maybe using a multi-select listbox isn't the way to go??? Any
ideas? Thanks.
Nov 12 '05 #1
2 1990
Ellen Manning wrote:
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 per year/month per doctor.

I've got the form set up and I can enter one year and the months but
can't figure out how to navigate to a fresh screen and enter the next
year. Maybe using a multi-select listbox isn't the way to go??? Any
ideas? Thanks.


Why not? I am not sure how many columns you have. You can see in my
example I use 0 as the first column is the column I want to use (the
column property starts at zero so if you have 5 columns, it is 0-4).

I would have a button to update the months to igrnore in the table.
Let's say your table has the fields called DoctorID, YearAvail, and the
months are Yes/No for availability and are called Jan...Dec. On the
form you have a DoctorID field you are working on, the YearAvail. The
listbox name is called ListMon. The listbox has 1 column; Jan...Dec

Sub CommandSelectAvailability_Click

'no need to process if doctorid or year is empty.
If IsNull(Me.DoctorID) Or IsNull(Me.YearAvail) Then Exit Sub

Dim var As Variant
Dim strMon As STring
Dim intFor As Integer
Dim intYear As Integer
Dim rst As DAO.Recordset

Set rst = Currentdb.openrecordset("Availability",dbopendynas et)

'find the doctor record for the year
rst.findfirst "DoctorID = " & Me.DoctorID & " And " _
"YearAvail = " & Me.YearAvail

'if found, edit the availablity record else add one.
If not rst.nomatch then
rst.Edit
Else
'if not found, create a new record
rst.AddNew
rst!DoctorID = Me.DoctorID
rst!Year = Me.YearAvail
Endif

'if editing, clear out any settings first
intYear = Year(Date())
For intFor = 1 to 12
'assign to variable Jan-Dec
strMon = Format(DateSerial(intYear,intFor,1),"mmm")

'now set that month to false
rst(strMon) = False
Next

'loop through all selected months and set to Available = True
For Each var In Me.ListMon.ItemsSelected
'assign the month to true
strMon = Me.ListMon.Column(0, var)
rst(strMon) = True

'now de-select that month
Me.ListMon.Selected(var) = False
Next

'commit the changes and close recordset
rst.Update
rst.close
set rst = Nothing

'clear out the Year
Me.YearAvail = Null

'keep the same doctor. go to the doctor field
Me.DoctorID.SetFocus
End Sub

I would probably have a routine that once a doctorID and Year is
entered to see if the record exists and set the Selected property to
true so you can see what has already been selected. I've provided
enough code for you to see how that can be done. Instead of looping
through the list of ItemsSeleted, you would do a loop using
For I = 0 TO Me.ListMOn.ListCount -1
...set month to true or false for existing records
Next
Nov 12 '05 #2
Ellen Manning wrote:
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 per year/month per doctor.

I've got the form set up and I can enter one year and the months but
can't figure out how to navigate to a fresh screen and enter the next
year. Maybe using a multi-select listbox isn't the way to go??? Any
ideas? Thanks.


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The list box method of selecting months is OK, but you have to know that
all the selected values (records) will have to be written to the table
one-at-a-time. You can use a stored procedure (SP) & VBA code. Example
of the SP:

CREATE PROCEDURE usp_AddDoctorUnavailable
- -- If the DoctorNotAvailable table has more than these columns
- -- you will have to adjust the SP & the VBA code to insert those
- -- columns.

@DoctorID INTEGER ,
@Month DATETIME -- Format YYYYMM01

AS

INSERT INTO DoctorNotAvailable (DoctorID, Month)
VALUES (@DoctorID, @Month)

====

There should be a CommandButton on the form that saves the data to the
table "DoctorNotAvailable" (use the real table's name). E.g.
(untested):

Private Sub cmdSave_Click()
' In:
' Me!lstMonths The months to save
' Me!txtDoctorID The doctor's ID
' Me!txtYear The year the months are in
'

Dim cn As New ADODB.Connection
Dim strSQL As String
Dim strExec As String
Dim varRow as Variant

On Error GoTo err_

cn.Connection = CurrentProject.Connection
cn.Open

strSQL = "EXEC usp_AddDoctorUnavailable " & Me!txtDoctorID & ", "

' Assumes the list box's bound column returns the month number,
' and that txtYear holds a 4-digit year.
For Each varRow In Me!lstMonths.ItemsSelected
With Me!lstMonths
' Format the date to "YYYYMM01" & attach to EXEC statement.
' Note: single quotes have to surround the date value.
strExec = strSQL & " '" & Me!txtYear & _
Format(.ItemData(varRow),"00") & "01'"
cn.Execute strExec,,adCmdText
End With
Next varRow

' If reached here - success!
' Clear the selected values from the list box
' to show the user that the info was saved.
' Or show a MsgBox saying saved.
With Me!lstMonths
For Each varRow In .ItemsSelected
.Selected(varRow) = False
Next varRow
End With

exit_:
cn.Close
Set cn = Nothing
Exit Sub

err_:
' You may want to check for duplicates & just Resume Next
' instead of running the MsgBox.
MsgBox "An error occurred while saving the Doctor's " & _
"Unavailable months" & vbcr & vbcr & "Error: " & _
err.Description, vbCritical
Resume exit_

End Sub

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQH2udYechKqOuFEgEQK7ygCgkHfBI/HrAT4myW0qLQ50aeXwuOgAoLeY
rE92g44aXedjv2946IxhwxIY
=kzJ9
-----END PGP SIGNATURE-----

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

37
by: ajikoe | last post by:
Hello, Is anyone has experiance in running python code to run multi thread parallel in multi processor. Is it possible ? Can python manage which cpu shoud do every thread? Sincerely Yours,...
4
by: Frank Jona | last post by:
Intellisense with C# and a multi-file assembly is not working. With VB.NET it is working. Is there a fix availible? We're using VisualStudio 2003 Regards Frank
12
by: * ProteanThread * | last post by:
but depends upon the clique: ...
0
by: frankenberry | last post by:
I have multi-page tiff files. I need to extract individual frames from the multi-page tiffs and save them as single-page tiffs. 95% of the time I receive multi-page tiffs containing 1 or more black...
6
by: cody | last post by:
What are multi file assemblies good for? What are the advantages of using multiple assemblies (A.DLL+B.DLL) vs. a single multi file assembly (A.DLL+A.NETMODULE)?
4
by: mimmo | last post by:
Hi! I should convert the accented letters of a string in the correspondent letters not accented. But when I compile with -Wall it give me: warning: multi-character character constant Do the...
5
by: Shane Story | last post by:
I can seem to get the dimensions of a frame in a multiframe tiff. After selecting activeframe, the Width/Height is still really much larger than the page's actual dimensions. When I split a...
5
by: bobwansink | last post by:
Hi, I'm relatively new to programming and I would like to create a C++ multi user program. It's for a project for school. This means I will have to write a paper about the theory too. Does anyone...
0
by: Sabri.Pllana | last post by:
We apologize if you receive multiple copies of this call for papers. *********************************************************************** 2008 International Workshop on Multi-Core Computing...
1
by: mknoll217 | last post by:
I am recieving this error from my code: The multi-part identifier "PAR.UniqueID" could not be bound. The multi-part identifier "Salary.UniqueID" could not be bound. The multi-part identifier...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
jinu1996
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.