Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA question


This is not an excel question but a VBA one. I want to firstl
apologize for that but I know there are a lot of VBA gurus around.

I am trying to populate some fields in Access depending on what th
user puts in. To keep the example clear, I have a Message Bo
(MessHist), A Text Box (Textbox), a Combo Box (NewAssign) and a Chec
Box (Check44).

When a button is pressed, it first makes

MessHist = MessHist & Textbox

then check if NewAssign is a new value
If yes, assign new value, attach message to MessHist, if no, leav
Messhist alone

Then check if checkbox is checked
If yes, assign new value, attach message to MessHist, if no, leav
MessHist alone.

Here is the code I have .. the problem I run into is when I have a ne
value in NewAssign AND the checkbox checked. The two messaged are no
being generated. But it works fine if only the NewAssign value change
or Checkbox is checked. any help would be greatly appreciated

Private Sub BtnSbmt2_Click()

Dim Temp As String
Dim IDstamp As String
Dim Timestamp As String

Timestamp = Date & " " & Time()
IDstamp = DLookup("[FirstName] & ' ' & [LastName]", "Contacts"
"[ID] = " & [OpenedBy])

MessHist = MessHist & vbCrLf & Timestamp & " - " & IDstamp
vbCrLf & " " & Textbox & vbCrLf

If NewAssign < AssignedTo Then
AssignedTo = NewAssign
MessHist = MessHist & vbCrLf & Timestamp & " - " & IDstam
& vbCrLf & " " & Textbox & vbCrLf & vbCrLf & Timestamp & " **
Message Re-assigned to " & DLookup("[FirstName] & ' ' & [LastName]"
"Contacts", "[ID] = " & [AssignedTo]) & " ***" & vbCrLf
Else
If Check44.Value = True Then
Status = "Closed"
MessHist = MessHist & vbCrLf & Timestamp & " - " & IDstam
& vbCrLf & " " & Textbox & vbCrLf & Timestamp & " *** Messag
Closed by " & IDstamp & " ***" & vbCrLf
End If
End If

Textbox.Value = Null
Me.Refresh

End Su

--
Bearacad

-----------------------------------------------------------------------
Bearacade's Profile: http://www.excelforum.com/member.php...fo&userid=3501
View this thread: http://www.excelforum.com/showthread.php?threadid=56221

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA question


I changed the Else to just end the if. I am still coming up with th
similar problem. I know I am putting something in wrong. Forwhateve
reason, it us bypassing the assigned to code when checkbox i
checked...

Private Sub BtnSbmt2_Click()

Dim Temp As String
Dim IDstamp As String
Dim Timestamp As String

Timestamp = Date & " " & Time()
IDstamp = DLookup("[FirstName] & ' ' & [LastName]", "Contacts"
"[ID] = " & [OpenedBy])

MessHist = MessHist & vbCrLf & Timestamp & " - " & IDstamp
vbCrLf & " " & Textbox & vbCrLf

If NewAssign < AssignedTo Then
AssignedTo = NewAssign
MessHist = MessHist & vbCrLf & Timestamp & " - " & IDstam
& vbCrLf & " " & Textbox & vbCrLf & vbCrLf & Timestamp & " **
Message Re-assigned to " & DLookup("[FirstName] & ' ' & [LastName]"
"Contacts", "[ID] = " & [AssignedTo]) & " ***" & vbCrLf
End If

If Check44.Value = True Then
Status = "Closed"
MessHist = MessHist & vbCrLf & Timestamp & " - " & IDstam
& vbCrLf & " " & Textbox & vbCrLf & Timestamp & " *** Messag
Closed by " & IDstamp & " ***" & vbCrLf
End If

Textbox.Value = Null
NewAssign.Value = Null
Check44.Value = Null
Me.Refresh

End Su

--
Bearacad

-----------------------------------------------------------------------
Bearacade's Profile: http://www.excelforum.com/member.php...fo&userid=3501
View this thread: http://www.excelforum.com/showthread.php?threadid=56221

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default VBA question

If this is for Access, then shouldn't you ask in an Access newsgroup?

Bearacade wrote:

This is not an excel question but a VBA one. I want to firstly
apologize for that but I know there are a lot of VBA gurus around.

I am trying to populate some fields in Access depending on what the
user puts in. To keep the example clear, I have a Message Box
(MessHist), A Text Box (Textbox), a Combo Box (NewAssign) and a Check
Box (Check44).

When a button is pressed, it first makes

MessHist = MessHist & Textbox

then check if NewAssign is a new value
If yes, assign new value, attach message to MessHist, if no, leave
Messhist alone

Then check if checkbox is checked
If yes, assign new value, attach message to MessHist, if no, leave
MessHist alone.

Here is the code I have .. the problem I run into is when I have a new
value in NewAssign AND the checkbox checked. The two messaged are not
being generated. But it works fine if only the NewAssign value changed
or Checkbox is checked. any help would be greatly appreciated

Private Sub BtnSbmt2_Click()

Dim Temp As String
Dim IDstamp As String
Dim Timestamp As String

Timestamp = Date & " " & Time()
IDstamp = DLookup("[FirstName] & ' ' & [LastName]", "Contacts",
"[ID] = " & [OpenedBy])

MessHist = MessHist & vbCrLf & Timestamp & " - " & IDstamp &
vbCrLf & " " & Textbox & vbCrLf

If NewAssign < AssignedTo Then
AssignedTo = NewAssign
MessHist = MessHist & vbCrLf & Timestamp & " - " & IDstamp
& vbCrLf & " " & Textbox & vbCrLf & vbCrLf & Timestamp & " ***
Message Re-assigned to " & DLookup("[FirstName] & ' ' & [LastName]",
"Contacts", "[ID] = " & [AssignedTo]) & " ***" & vbCrLf
Else
If Check44.Value = True Then
Status = "Closed"
MessHist = MessHist & vbCrLf & Timestamp & " - " & IDstamp
& vbCrLf & " " & Textbox & vbCrLf & Timestamp & " *** Message
Closed by " & IDstamp & " ***" & vbCrLf
End If
End If

Textbox.Value = Null
Me.Refresh

End Sub

--
Bearacade

------------------------------------------------------------------------
Bearacade's Profile: http://www.excelforum.com/member.php...o&userid=35016
View this thread: http://www.excelforum.com/showthread...hreadid=562219


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA question

You are right, and I did ask in other access forums. I weren't able to
find the help that I need and the VBA codes are fairly similar in both
applications. I know it's a something I am overlooking or I am
missing, probably just syntax. Perhaps you can help me out? Thanks in
advance.

Dave Peterson wrote:
If this is for Access, then shouldn't you ask in an Access newsgroup?

Bearacade wrote:

This is not an excel question but a VBA one. I want to firstly
apologize for that but I know there are a lot of VBA gurus around.

I am trying to populate some fields in Access depending on what the
user puts in. To keep the example clear, I have a Message Box
(MessHist), A Text Box (Textbox), a Combo Box (NewAssign) and a Check
Box (Check44).

When a button is pressed, it first makes

MessHist = MessHist & Textbox

then check if NewAssign is a new value
If yes, assign new value, attach message to MessHist, if no, leave
Messhist alone

Then check if checkbox is checked
If yes, assign new value, attach message to MessHist, if no, leave
MessHist alone.

Here is the code I have .. the problem I run into is when I have a new
value in NewAssign AND the checkbox checked. The two messaged are not
being generated. But it works fine if only the NewAssign value changed
or Checkbox is checked. any help would be greatly appreciated

Private Sub BtnSbmt2_Click()

Dim Temp As String
Dim IDstamp As String
Dim Timestamp As String

Timestamp = Date & " " & Time()
IDstamp = DLookup("[FirstName] & ' ' & [LastName]", "Contacts",
"[ID] = " & [OpenedBy])

MessHist = MessHist & vbCrLf & Timestamp & " - " & IDstamp &
vbCrLf & " " & Textbox & vbCrLf

If NewAssign < AssignedTo Then
AssignedTo = NewAssign
MessHist = MessHist & vbCrLf & Timestamp & " - " & IDstamp
& vbCrLf & " " & Textbox & vbCrLf & vbCrLf & Timestamp & " ***
Message Re-assigned to " & DLookup("[FirstName] & ' ' & [LastName]",
"Contacts", "[ID] = " & [AssignedTo]) & " ***" & vbCrLf
Else
If Check44.Value = True Then
Status = "Closed"
MessHist = MessHist & vbCrLf & Timestamp & " - " & IDstamp
& vbCrLf & " " & Textbox & vbCrLf & Timestamp & " *** Message
Closed by " & IDstamp & " ***" & vbCrLf
End If
End If

Textbox.Value = Null
Me.Refresh

End Sub

--
Bearacade

------------------------------------------------------------------------
Bearacade's Profile: http://www.excelforum.com/member.php...o&userid=35016
View this thread: http://www.excelforum.com/showthread...hreadid=562219


--

Dave Peterson


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default VBA question

I don't use Access, so I don't have a guess.



wrote:

You are right, and I did ask in other access forums. I weren't able to
find the help that I need and the VBA codes are fairly similar in both
applications. I know it's a something I am overlooking or I am
missing, probably just syntax. Perhaps you can help me out? Thanks in
advance.

Dave Peterson wrote:
If this is for Access, then shouldn't you ask in an Access newsgroup?

Bearacade wrote:

This is not an excel question but a VBA one. I want to firstly
apologize for that but I know there are a lot of VBA gurus around.

I am trying to populate some fields in Access depending on what the
user puts in. To keep the example clear, I have a Message Box
(MessHist), A Text Box (Textbox), a Combo Box (NewAssign) and a Check
Box (Check44).

When a button is pressed, it first makes

MessHist = MessHist & Textbox

then check if NewAssign is a new value
If yes, assign new value, attach message to MessHist, if no, leave
Messhist alone

Then check if checkbox is checked
If yes, assign new value, attach message to MessHist, if no, leave
MessHist alone.

Here is the code I have .. the problem I run into is when I have a new
value in NewAssign AND the checkbox checked. The two messaged are not
being generated. But it works fine if only the NewAssign value changed
or Checkbox is checked. any help would be greatly appreciated

Private Sub BtnSbmt2_Click()

Dim Temp As String
Dim IDstamp As String
Dim Timestamp As String

Timestamp = Date & " " & Time()
IDstamp = DLookup("[FirstName] & ' ' & [LastName]", "Contacts",
"[ID] = " & [OpenedBy])

MessHist = MessHist & vbCrLf & Timestamp & " - " & IDstamp &
vbCrLf & " " & Textbox & vbCrLf

If NewAssign < AssignedTo Then
AssignedTo = NewAssign
MessHist = MessHist & vbCrLf & Timestamp & " - " & IDstamp
& vbCrLf & " " & Textbox & vbCrLf & vbCrLf & Timestamp & " ***
Message Re-assigned to " & DLookup("[FirstName] & ' ' & [LastName]",
"Contacts", "[ID] = " & [AssignedTo]) & " ***" & vbCrLf
Else
If Check44.Value = True Then
Status = "Closed"
MessHist = MessHist & vbCrLf & Timestamp & " - " & IDstamp
& vbCrLf & " " & Textbox & vbCrLf & Timestamp & " *** Message
Closed by " & IDstamp & " ***" & vbCrLf
End If
End If

Textbox.Value = Null
Me.Refresh

End Sub

--
Bearacade

------------------------------------------------------------------------
Bearacade's Profile:
http://www.excelforum.com/member.php...o&userid=35016
View this thread: http://www.excelforum.com/showthread...hreadid=562219


--

Dave Peterson


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007 Macro/VB Question DDE Question MadDog22 Excel Worksheet Functions 1 March 10th 10 01:47 AM
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good davegb Excel Programming 1 May 6th 05 06:35 PM
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you [email protected] Excel Programming 0 April 27th 05 07:46 PM
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you [email protected] Excel Programming 23 April 23rd 05 09:26 PM
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you [email protected] Excel Programming 0 April 22nd 05 03:30 PM


All times are GMT +1. The time now is 03:48 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"